Re: [Puppet Users] Variable Scoping: What do you want?

Patrick Mohr
2010-06-30T19:47:09Z

On Jun 30, 2010, at 8:33 AM, R.I.Pienaar wrote:

> hey
>
> ----- "Patrick Mohr" <kc7zzv@gmail.com> wrote:
>
>> On Jun 30, 2010, at 3:09 AM, R.I.Pienaar wrote:
>>
>>>
>>> ----- "Trevor Vaughan" <tvaughan@onyxpoint.com>
wrote:
>>>
>>>> Also, I''m not entirely convinced that variables
can''t be
>> overridden.
>>>> I understand that the final compilation is order independent,
but
>> I
>>>> believe that the initial run is file order dependent. I.e. if
you
>>>> don''t declare an ''include'' before an
''if'' statement checking for
>> the
>>>> included class, then you end up with an ''if''
that is not called.
>> Could the
>>>> variable parsing be moved to this layer?
>>>
>>> I''d call this parsing behavior a bug, see my comment about
>> defined(), it''s
>>> related to that
>>>
>>> http://projects.reductivelabs.com/issues/3049
>>
>> By the way, ignoring the technical aspect, how do you think defined
>> should work in this case? In this case, what aleart should be printed,
>> or what error should be printed?  This is a rather contrived example,
>> but I''m not really sure what puppet should actually do here
with your
>> suggestion.  (Please excuse my syntax errors).
>>
>>
>>
>> node ''test-node'' {
>> 	include classA
>> 	include classB
>> }
>>
>>
>> class classA {
>> 	if !defined Package[''apache'']
>> 	{
>> 		package { ''apache'':
>> 			ensure => installed,
>> 		}
>>
>> 		alert("Package apache included by classA")
>> 	}
>> }
>>
>> class classB {
>> 	if !defined Package[''apache'']
>> 	{
>> 		package { ''apache'':
>> 			ensure => installed,
>> 		}
>>
>> 		alert("Package apache included by classB")
>> 	}
>> }
>
>
> This would fall under the umbrella of bad manifest design :) I''d
expect it to print different alerts between runs - today it would be
predictable, i think but I wouldnt treat that as something to rely on.

I agree it''s bad design and I''m not using that code, but I
think you need to know how puppet should treat this case before the problem can
be fixed.