On Feb 8, 12:43 am, jimbob palmer <jimbobpal...@gmail.com> wrote: > Thanks. but I meant more within the same class: before I was using > class inheritance to ensure that I don't have to worry about ordering.
Class foo::specific 'include'ing class foo::common on the first line of its body gives exactly the same ordering guarantees that would be afforded by foo::specific inheriting from foo::common, so inheritance gains you nothing special there. Moreover, those guarantees are *entirely* with respect to catalog compilation (on the master), not the order in which resources are applied to your nodes by the agent. To influence the order in which resources are applied, you need to set up relationships between resources and / or classes. That is what the 'require' variant of the 'include' function, resources' require / before / listen / notify metaparameters, and the resource chaining operators are for. > Now I will use includes as you suggest. Say I have a class that has an > include, is there a guarantee that the include will always be included > before the rest of the class is examined? When you use the 'include' function, you can rest assured that the declarations you have included will be visible to all code that follows the inclusion within the same scope (that is, within the same class, defined type, or node definition) in top-to-bottom order. All class, resource, and type declarations are globally visible once they are parsed, so once you have 'include'd a class, that class and all the resources it declares are also visible to classes referenced by subsequent 'include' calls. > >> And a related question: if I have a case statement at the top of my > >> class that sets a variable, how can I be sure the variable will be set > >> before I need it lower down in the same class? > > > If you mean there's a variable in foo::common you want to reference in > > foo::specific just use fully qualified variable and include > > foo::common. > > I mean withint the same class. Say I have a case statement at the top > of my class that sets a variable, will that run before I need the > variable (later in the same class)? Puppet processes each manifest file in order from top to bottom. Declarations appearing earlier in the file are guaranteed to be visible to code later in the file. 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.