Ask Your Question
0

custom value of a structured fact item

asked 2018-02-01 09:32:16 -0500

peterb gravatar image

hi,

since the stock 'networking' fact does not find the correct "primary" network interface in my case since there is another interface with the default route, i am trying to modify only the 'networking.ip' and 'networking.primary' value of this stuctured fact. Its straight-forward to replace the whole fact but how could i keep the stock values of the other items? As soon as i obtain the current value of the fact with

stock_fact = Facter.value(:networking)

the fact is resolved and there seems to be no way of modifying it afterwards.

edit retag flag offensive close merge delete

Comments

You can add hashes, where keys in the second operand take higher precedence (override any values in the first operand).

Kai Burghardt gravatar imageKai Burghardt ( 2018-02-01 11:06:42 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-01 11:34:30 -0500

peterb gravatar image

I think i don't get it. You mean the second operand of the Facter.value method like this?

Facter.add(:networking, { :value => "mynetworking" }) do
  has_weight 200
  setcode do
    "does not matter whats here"
  end
end

This sets "mynetworking" as value of the fact but if i retrieve the stock values before calling Facter.add, the stock fact code is evaluated and can not be modified later on. So with the following code i still end up with the stock values of the "networking" fact:

networking_fact_values = Facter.value(:networking)
Facter.add(:networking, { :value => "mynetworking" }) do
  has_weight 200
  setcode do
    "does not matter whats here"
  end
end
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-02-01 09:31:49 -0500

Seen: 51 times

Last updated: Feb 01