[Prev] Thread [Next]  |  [Prev] Date [Next]

[Puppet Users] Re: local vs global variables jcbollinger Tue Apr 03 07:00:46 2012

On Apr 3, 3:17 am, Pablo Fernandez <[EMAIL PROTECTED]> wrote:
> class data::group_wn {
>      # This is needed to connect freely from/to the CE
>      $sshd_HostbasedAuthentication = 'yes'
>      $sshd_IgnoreUserKnownHosts = 'yes'
> }
> class data::group_ppwn inherits data::group_wn {
>      # We can override any value here
> }
> I do it this way, because I have the production group (group_wn) and the
> pre-production group (group_ppwn), and I want them to be cloned, but I
> want to be able to override values in the pre-production group (and
> avoid repeating the same values in a completely separated group schema).
> I have tried doing that, and the overrides work quite nicely, but...
> could it be that the Facts are also inherited? It really seems like,
> otherwise why would Hiera stop looking there?

I'm still thinking about this.  The messages about dynamic lookup of
$netmask are pointing toward the theory I proposed before: variable
lookup in the context of an existing class that does not itself define
a local $netmask variable is pulling in $::netmask (or maybe a
containing class's or superclass's $foo::netmask).  If it's $::netmask
getting pulled in, however, then I don't understand why lookup stops
in the *second* class instead of in the first.

Do note, however, that you should be very careful with the variable
"override" idea.  In particular, you need to understand that Puppet
doesn't have any such concept: what you are actually doing is _hiding_
variables declared in outer scopes.  The difference is that hiding a
variable is scope-dependent.  Both variables still exist, and which
value you get in any expression depends on that expression's context.
I would recommend avoiding such usage.  In fact, I would typically
recommend Hiera as an alternative -- use the data hierarchy instead of
a class hierarchy to do this for you .


You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at