Thanks guys, I did not realize "defined" was for resources only, not variables.

The custom fact is created using a custom fact creator "fact", which
makes other custom facts out of strings in a text file. the text file
itself is managed by puppet.

http://www.devco.net/archives/2008/06/16/rework_of_puppet_facts_for_etcfactstxt.php

And so it is normal that the text file based custom facts do not exist
in the first run...

Thanks,
Mohamed.


On Thu, Oct 13, 2011 at 8:59 AM, jcbollinger <john.bollin...@stjude.org> wrote:
>
>
> On Oct 12, 4:23 pm, Mohamed Lrhazi <lrh...@gmail.com> wrote:
>> I have a custom fact called:  gu_app_oracle_rac
>>
>> Which gets set, indirectly, by puppet itself... and so in the very
>> first run it does not exist... I will be changing the whole business
>> of how I set these facts, but I need a quick workaround to the
>> following issue...
>>
>> I have some templates using that variable and so the first run fails
>> because the var is undefined, and so I added this to site.pp:
>>
>> if !defined(gu_app_oracle_rac) {
>>     $gu_app_oracle_rac = false
>>
>> }
>>
>> Now, this allows the first run, maybe a few, to work... then when the
>> fact comes to life, I get:
>>
>> Cannot reassign variable gu_app_oracle_rac in site.pp
>>
>> Why doesn't the *if* statement do what I expect it to do?
>
>
> Amplifying what Nan said, the 'defined' function is documented to be
> for use with classes, resource types, and resource instances.  In your
> case, therefore, it is looking for a class or definition named
> "gu_app_oracle_rac", and returning false when it doesn't find one.
> Even if it worked on variables, however, 'defined' is parse-order
> dependent and Puppet parse order is unpredictable, so using 'defined'
> is never a good idea.  Ever.
>
> As to the underlying problem, I'm confused about your description.  If
> gu_app_oracle_rac is a custom fact, then aren't you delivering it to
> clients via pluginsync?  If so then it should be available on every
> run, including the first.
>
>
> John
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@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