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

Patrick Mohr
2010-06-30T15:07:07Z

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")
	}
}