Suppose I have a module in puppet that creates custom facts. But to do so, it requires a package package_a
to be installed. Based on whether this package is there or not it will decide to generate the facts.
This package is installed as part of the puppet run in a profile. So initially the facts will not be generated from the module.
Once the package is installed that is used to generate the custom facts, is there any way to notify puppet to gather these facts so it can be used in following profiles?
The module that adds the custom facts:
Facter.add(:custom_facts) do
confine do
exists = Facter::Core::Execution.which('package_a') != nil
Puppet.debug "Testing custom_facts fact applicable? #{exists.inspect}"
true
end
setcode do
to_ret = {}
result = JSON.parse(Facter::Core::Execution.execute('package_a some command'))
Puppet.debug "Facts returned by command: #{result.inspect}"
result.each do |key,value|
to_ret[key]={
'value' => value['value'],
}
end
to_ret
end
end