On Tuesday, September 10, 2013 8:53:10 AM UTC-5, sjr wrote:
>
> Hi John,
>
> thanks for your answer, first of all I must say I just wanted to 
> experiment and learn, it's not like I'm going to put such "awful hacks" :-) 
> in production....mostly because I guess it's easy they can be changed over 
> the time as they are not part of puppet DSL and so, it can be harder to 
> maintain and for other colleagues to understand.
>
> OK, now to the point...I forgot to include the node definition, sorry 
> about that, it looks like:
>
> node hostname {
>   class {'test1': }
>   test1::print {'test11':
>     message => 'test11',
>   }
>   test1::print {'test12':
>     message => 'test13',
>   }
>   test1::print {'test13':
>     message => 'test13',
>   }
>
> So I understand that when you say I haven't defined any resource it's 
> because I forgot to mention that part, right?
>


Yes.

 

> If so, why the define types are not showing up in the file?
>


You have not fully appreciated the implications of the evaluation-order 
dependency of scope.catalog.resources.  The defined-type instances are not 
showing up in the file because their declarations have not yet been 
evaluated when the template is evaluated.  Overall evaluation order is 
difficult to predict, and it is not stable with respect changes in your 
manifest set.  I cannot emphasize strongly enough how important it is to 
avoid evaluation-order dependencies in your Puppet code.

 

> Also, as you can see in the content of the file I included in my previous 
> message, Class[test1] was declared and showed in the content of the file, 
> but the File resource itself was not there when the template was built.
>


Of course it wasn't.  The value of the File's 'content' parameter is 
generated by evaluating the template via the template() function (on the 
master, during catalog compilation, the same as all Puppet functions are 
executed).  Puppet must compute the values of the resource's parameters 
before it can add the resource to the catalog.

 

>
> I have the feeling the template is evaluated before all this resources are 
> present in the catalog...am I wrong? Is that expected behavior?
>
>

As described above, in this case the template will reliably be evaluated 
before the File because the template evaluation is subsidiary to the File's 
declaration.  Also, it happens that the template is evaluated before the 
three declarations of Test1::Print instances, but you should not 
over-interpret that result.  In particular, you should not use it to try to 
predict evaluation order within other manifest sets.  That should not be a 
problem, however, since you will be carefully avoiding code for which 
evaluation order males any difference.  Right?


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to