On 20 November 2010 16:42, Nigel Kersten <ni...@puppetlabs.com> wrote:
> On Fri, Nov 19, 2010 at 12:56 PM, Steve Atwell <satw...@google.com> wrote:
>> I need to write a custom fact that depends on the value of another
>> custom fact in a different file.  For example:
>>
>> # foo.rb
>> Facter.add("foo") do
>>    setcode do
>>        [...]
>>    end
>> end
>>
>> # bar.rb
>> Facter.add("bar") do
>>    setcode do
>>        if (Facter.value("foo") == "option1") then
>>            [...]
>>        else
>>            [...]
>>        end
>>    end
>> end
>>
>> Do I need to do anything to ensure that the foo fact is added before
>> the bar fact's block is evaluated?  Or does puppet load all facts
>> before evaluating any of them?
>
> Hi Steve, this will do the right thing, you don't have to ensure foo
> is added first.

I'm not sure this is true in all cases, although quickly testing with
a fact/filename mismatch this does work.

It used to be in some cases you may have to force a loadfacts as mentioned in

http://projects.puppetlabs.com/projects/1/wiki/Adding_Facts

Testing using irb shows the issue using a facts dir containing:

https://gist.github.com/714987

FACTERLIB=$(pwd)/facts irbirb(main):001:0> require 'facter'
=> true
irb(main):002:0> Facter.value('bar')
=> "default"


Paul

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to