I would like to read value from the hiera for my custom factor. Is it possible ?
I am going to populate a factor based on my hiera value. Please look at my following code for your reference.
require 'facter'
# Default for non-Linux nodes
Facter.add(:jboss_base_algorithm) do
setcode do
nil
end
end
# Linux
#
Facter.add(:jboss_base_algorithm) do
confine :kernel => :linux
setcode do
Facter::Util::Resolution.exec("/usr/bin/echo '{hiera_value}' | /usr/bin/base64")
end
end
Any help is much appreciated.
Custom facts cannot rely on Hiera in a master / agent configuration, because facts are evaluated by the agent whereas the Hiera data live on the master.
Custom facts probably shouldn't rely on Hiera data even for local manifest application, in part because that inhibits switching to master / agent, and in part because the data are already accessible directly from Hiera. You don't need a custom fact to access the data.