On Aug 10, 2012, at 6:11 PM, Denmat wrote:

> 
> 
> On 11/08/2012, at 7:27, Douglas Garstang <[email protected]> wrote:
> 
>> On Fri, Aug 10, 2012 at 2:24 PM, llowder <[email protected]> wrote:
>>> 
>>> 
>>> On Friday, August 10, 2012 3:52:42 PM UTC-5, Douglas wrote:
>>>> 
>>>> On Fri, Aug 10, 2012 at 1:42 PM, llowder <[email protected]> wrote:
>>>>> 
>>>>> 
>>>>> On Friday, August 10, 2012 3:28:33 PM UTC-5, Douglas wrote:
>>>>>> 
>>>>>> So...
>>>>>> 
>>>>>> I was just reading the new puppet scoping documentation at
>>>>>> http://docs.puppetlabs.com/guides/scope_and_puppet.html.
>>>>>> 
>>>>>> I don't get it. If I have this...
>>>>>> 
>>>>>> class web_server {
>>>>>>   include common
>>>>>>   include webserver
>>>>>>   $my_role = "web_server"
>>>>>> }
>>>>>> 
>>>>>> Can I access the $my_role variable in the webserver class?
>>>>> 
>>>>> 
>>>>> If you use: $web_server::my_role
>>>> 
>>>> This seems completely screwed to me. What if your in a general class,
>>>> one not necessarily related to the function of a web server (but still
>>>> included from a web server), and you need to access the role?
>>>> 
>>> 
>>> Then use the fully qualified variable name as I mentioned in my last post.
>> 
>> What if the class I am in doesn't KNOW that the parent is $web_server ...?
>> 
>> Doug.
>> 
> What if you've declared my_role in several classes? This provides certainty. 
> Alternatively you could make a fact that has the value you want of my_role 
> and reference that in the top scope $::my_role.

It is called: "Making an honest attempt to help you avoid shooting your own 
toes off".

By forcing you to specifically reference the class name along with the variable 
name (that includes the top scope $::foo), it saves you extensive grief down 
the road when you eventually end up with the same variable name in multiple 
classes.

Or would you rather have to track all the variable names in all the classes you 
use (the ones you write yourself along with ones you pull from places like the 
Puppet Forge) to ensure unique variable names ?


-- 
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 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to