On Monday, July 1, 2013 9:17:11 PM UTC-5, Daniel Jung wrote: > > Hi Wolf, > > I guess you can use the lookupvar and specifically call the variable from > the class where it belongs to. That would be one method of doing it and > probably works with Puppet 3.* as well. > I just want to get my head around the scope while calling templates from a > manifest. > > Yes, you can use scope.lookupvar() to retrieve the value of a variable of any class by passing the qualified name of the variable. And that is what your templates *should* do if they need to query variables from outside the local scope where they are evaluated. This works in Puppet 2 and Puppet 3.
Before dynamic scoping was removed (i.e. before Puppet 3), a template might, under some circumstances, be able to directly access variables belonging to other scopes, such as in your example code. That was never a good idea, however, for exactly the same reasons that dynamic scoping in general was not a good idea. The potential gotcha with looking up variables of other classes is that you must make sure that a declaration of the host class has already been parsed before the template is evaluated. That's not necessarily a big problem, but you can expect to be bitten in the behind if you forget to do it. John 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
