Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm going through a module that manages network, in order to understand how puppet modules work, what I'm stuck on is understanding what $::nisdomainname is, where did it come from and what does "$::" mean and why is the nisdomain portion outside the define block? An excerpt from a file in the module is below, can someone help me with the understanding?

define network::global (
  $hostnamemod = '',
  $gateway = '',
  $vlan = '',
  $nozeroconf = '',
  $gatewaydev = ''
) {
  $nisdomain = $::nisdomainname ? {
    ''      => '',
    default => $::nisdomainname,
  }

Thanks in advance Dan

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

In puppet 3.0 and newer, scoping rules will change and you can no longer use $variablename to refer to a variable in global scope, the correct syntax is $::variablename. This syntax also works in 2.7, and maybe in older versions too.

share|improve this answer
    
ahh thanks, but then why wouldn't the other variables like "hostnamemod" also be set as $::hostnamemod = ''? –  Dan Feb 6 '13 at 13:01
    
Because those are parameters to your define, not references to variables in global scope. –  Dennis Kaarsemaker Feb 6 '13 at 13:02
    
ok cleared it up now. Appreciate it. –  Dan Feb 6 '13 at 13:07
    
One final point, if I may. does the nisdomainname check state, that if the nisdomainname is empty set it to empty otherwise default to setting it to the $::nisdomainname. Which if not defined would be empty, am I right? –  Dan Feb 6 '13 at 13:07
1  
@DennisKaarsemaker It's not a requirement in 3.0 to specify top scope explicitly. The changes in 3.0 affect dynamic scope only. –  Shane Madden Feb 7 '13 at 4:44
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.