override individual items of a structured fact

8 views
Skip to first unread message

Peter Bauer

unread,
Feb 4, 2018, 2:01:58 AM2/4/18
to Puppet Users
hi,

since the stock 'networking' fact does not find the correct "primary" network interface in my case (there is another interface with the default route), i want to change the related 'networking.ip', 'networking.primary' values of this stuctured fact by writing a custom fact in Ruby. 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 stock 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. Basically its a chicken-and-egg problem but if there was the possibility to force a re-evaluate of the fact or define resolutions just for single items of a fact ...

here is the complete example: 

# get the stock value of the fact
networking_fact = Facter.value(:networking)
# add a resolution for the fact but this has no impact on the final value of the fact since Facter does not evaluate the fact again
Facter.add(:networking, { :value => "networking" }) do
  has_weight 200
  setcode do
    "does not matter what goes here"
  end
end

Reply all
Reply to author
Forward
0 new messages