Issue #20970 has been updated by Charlie Sharpsteen. Status changed from Unreviewed to Needs More Information Assignee set to Daniele Sluijters
Node variables are not part of global scope (aka top scope). They are confined to a node scope that exists between global scope and the scopes inhabited by classes, templates, etc. See the [scoping documentation](http://docs.puppetlabs.com/puppet/3/reference/lang_scope.html) for a full description. The node scope is an "[anonymous scope](http://docs.puppetlabs.com/puppet/3/reference/lang_scope.html#named-scopes-and-anonymous-scopes)" which means that no scope name component is added to the qualified name of variables set in node scope. This is because node scope is commonly used to override global variables on a per-node basis. So, to clarify this feature request: are you requesting that we change node scope from an anonymous scope to a named scope and add a new named scope for Facter variables? ---------------------------------------- Feature #20970: Scopes for node variables and facts https://projects.puppetlabs.com/issues/20970#change-91831 * Author: Daniele Sluijters * Status: Needs More Information * Priority: Normal * Assignee: Daniele Sluijters * Category: language * Target version: * Affected Puppet version: * Keywords: fact, facter, node, node variable, variable, scope, scoping * Branch: ---------------------------------------- Currently, variables declared on the node still magically appear in your local scope but can't be accessed as a top-scope variable. So: <pre><code> node default { $var = 'a' } </code></pre> Now, in every module, template, anywhere, ```$var``` will exist with a value of ```a``` unless overwritten in the local scope (I think). It would be nice if we could confine node level variables to their own scope, so we can access it like ```$::nodevar::var``` instead of ```$var``` and don't have a ```$var``` in our local scope unless we happen to define it there. I think it would lead to problems if the node level variables where automatically made part of the global scope since names might start to clash with facts and other things. Perhaps it would be wise to put facts in their own scope to, ```$::fact::osfamily```, which also immediately makes it a lot more obvious in the code (especially to newcomers) where that variable comes from. -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" 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-bugs?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
