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

David Schmitt
2010-07-02T08:56:06Z

On 6/30/2010 5:07 PM, Patrick Mohr wrote:
> 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")
> 	}
> }

In an ideal world, this is an invalid manifest. Especially when you add
more resources in there, that have different properties in classA vs
classB. The correct way to implement that would be to extract the
conditional resources into a common class.



Best Regards, David
--
dasz.at OG              Tel: +43 (0)664 2602670     Web: http://dasz.at
Klosterneuburg                                         UID: ATU64260999

        FB-Nr.: FN 309285 g          FB-Gericht: LG Korneuburg