I have the following file structure:
lib
└── facter
├── rackspace.rb
├── system_load.rb
└── users.rb
I want to use a custom fact value found in system_load.rb
(let's call this :system_me
fact) in another custom fact that I am writing and defined in users.rb
. Like this:
# users.rb
Facter.add('sogood') do
you = ''
me = Facter.value(:system_me)
if me == 'foo'
you = 'bar'
end
setcode do
you
end
end
However, I am worried on what happens if system_me
fact value doesn't exist yet before client tries to run sogood
.
So my question is:
rackspace.rb -> system_load.rb -> users.rb
) when I run puppet apply —facterpath=module/lib/facter
?If a fact resolution attempts to obtain the Facter.value()
for another fact that has not yet been loaded then Facter will immediately attempt to load the needed fact. That means that
You do need to avoid creating dependency loops among facts, but custom facts relying on built-in facts will never cause such a loop.