Yeah, that's probably not going to get you where you need to be. Scope in Puppet goes like this:
* When you declare a variable in a scope, it is local to that scope. * Every scope has one and only one "parent scope." * If it's a class or node that inherits from a base class/node, its parent scope is the base class/node. * Otherwise, a class or node's parent scope is the FIRST place where that class/node was evaluated. * If you try to evaluate a variable that doesn't exist in the current local scope, lookup proceeds through the chain of parent scopes -- its parent, the parent's parent, and so on, stopping at the first place it finds that variable. In your case, $auth_aaa is going to be true inside module1, but that's local to that module. module2 doesn't have that variable, so it's going to look in its parent scope, which is nodes.pp (well, nodes.pp + site.pp, because of the way import works), where the variable is false. Module1 can't spew its local variables all over its parent scope, which is by design. I can't tell from your description what you're trying to accomplish. I'm guessing you're ultimately trying to pass a parameter into a class, for which the long-term answer is parameterized classes. A lot of sites aren't ready to deploy those yet, though, so you have a couple options: * Use an external node classifier and set all your parameters at top scope according to whatever logic you need. All modules will look to their parent scope and find the right answer for the current node. * Define a parameters class that conditionally sets a bunch of variables based on facts like $operatingsystem or whatever. You can then have read-only access those variables everywhere with their fully- qualified name. $paramsclass::phppackage, or whatever. * Include one or two classes that include all your other classes. This gives you direct control over the parent scopes. Whichever you do, start trying to think in terms of passing parameters instead of setting variables. This'll get you more ready for the future of the language and will make your designs cleaner. Hope that helps. -NF (docs guy) On Feb 25, 12:10 pm, Mohamed Lrhazi <lrh...@gmail.com> wrote: > In my site.pp I have a var set to false > then I include a per_host module, which sets it for some host, to > true, the intent if for this new value to be used * thereafter* > I put I few notice statement in my manifests, and it seems my var that > get start as false, gets set to true in my per-host module, but is > then back to false in outer modules/classes.... > > How do you guys achieve what I am trying to do? I guess i don't > understand var scoping in Puppet.... > > In site.pp > > $auth_aaa = false > > In nodes.pp > > include module1 > include module2 > > module1: sets $auth_aaa to true > module2: still sees $auth_aaa to false > > Thanks a lot. > Mohamed. -- 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.