On Wed, Aug 8, 2012 at 6:25 AM, jcbollinger <john.bollin...@stjude.org> wrote: > > > On Tuesday, August 7, 2012 1:25:32 PM UTC-5, Douglas wrote: >> >> As usual, I'm confused about scope in puppet. This puppet 2.7.1. >> >> In my classes below, the bottom class, company::web::content, requires >> the file resource '/usr/local/company'. However, that resource is >> defined two includes back in the class company::common. I always >> thought this wasn't supposed to work, and that you could only access >> the immediate scope, not the scope of stuff beyond this. It does work >> however. Is it supposed to. Why? > > > Yes, it is supposed to. All classes and resources have global scope once > they are declared. The 'include' function does not introduce classes and > their resources into the current, innermost scope -- it doesn't need to do > so, and couldn't even if it wanted to do. Instead, 'include' ensures that > the specified class has been parsed and added to the catalog, which, as I > said, puts them into the global scope. > > The model pretty much has to work that way, because the physical resources > of the target node all have global scope, too. > > It is useful and appropriate for classes and definitions to 'include' (or > 'require') the classes on which they rely, provided that those classes are > not parametrized (Puppet <= 2.7.x). Aside from it's plain aggregation > function, that way it's a lot easier to make classes independent of the > order in which they are declared, plus it has documentary value. Classes > that 'include' all the classes on which they directly rely are more robust. > > However, there is no requirement for a class to 'include' its dependencies. > If a class does not do so, then it simply relies on those dependencies to > have been declared by some other class that was parsed before it. Users of > parametrized classes rely heavily on this, because parametrized classes can > be declared only once, but they may need to be referenced by many other > classes. >
Ok, so to put it another way, your saying that once a class is included, it's scope becomes global and can be used anywhere else, no matter the relationship between the class where it was included, and the class that's trying to access it? Doug. -- 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.