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

TomTom
2010-07-05T15:30:11Z

Hello All,
 Thanks for opening up this discussion to the community. I quickly
scanned through this thread, but didn''t see anything from Markus, does
he post under a different name.
 Not to side track the conversation, but could anyone explain why
variable scoping is the way it is in puppet? I "understand" how to use
variables in puppet (I ALWAYS use fully qualified variable names, and
I ALWAYS use myvar.lookup in my templates.) But, I struggle to
communicate to new puppet programmers why.

 Is it because puppet is "declarative", is this a "feature"
in
declarative languages? Is there a parallel in SQL?

 Is it a rubyism? I believe that String.sub! and String.sub change the
variables differently.

 Any light someone could shed on the background, would be greatly
appreciated.
 Have a nice July 5th.
-Tom

On Jul 5, 7:04 am, Matt <mattmora...@gmail.com>
wrote:
> On 5 July 2010 09:15, David Schmitt <da...@dasz.at> wrote:
>
>
>
>
>
> > On 7/5/2010 12:04 AM, Matt wrote:
>
> >> On 2 July 2010 09:50, David Schmitt<da...@dasz.at>  wrote:
>
> >>> On 6/30/2010 10:57 AM, Matt wrote:
>
> >>>> On 29 June 2010 17:22, Luke
Kanies<l...@puppetlabs.com>    wrote:
>
> >>>>> Hi all,
>
> >>>>> Given the number of threads on variable scoping
recently, it''s pretty
> >>>>> clear
> >>>>> we need to change how it works.  Markus has a lot of
this redone in his
> >>>>> futures branch, and I''m asking him to fully
describe what the results
> >>>>> will
> >>>>> be when that''s merged, but my guess is that
there are different
> >>>>> expectations
> >>>>> for what people want to see.
>
> >>>>> So, my question is, what behaviour changes would you
like to see in how
> >>>>> variable scoping works?  How would you like the edge
cases that are
> >>>>> currently hurting you to behave?
>
> >>>> I''d like to see the ability to reference and
change variables from
> >>>> other classes.
>
> >>>> class httpd { $monitor::services +=
''httpd1'' }
> >>>> class nginx { $monitor::services +=
''nginx'' }
>
> >>>> And if $monitor::services doesn''t exist then
it''s just created with
> >>>> one of the above rather than having to specify
$monitor::services = []
>
> >>>> Or use the new staging feature for ordering where I could
do:
>
> >>>> stage 1 includes class monitor { $monitor::services = [] }
> >>>> stage 2 includes class httpd, nginx as above
>
> >>> How is $monitor::service used, that this cannot read
>
> >>>  class httpd { monitor::service { ''httpd1'':
} }
> >>>  class nginx { monitor::service { ''nginx'': }
}
>
> >>> ?
>
> >> $monitor::service is used to monitor all services that are in that
> >> array.  So node include monitor, httpd, nginx
>
> >> class monitor { deploy monitoring for all services in
$monitor::service }
>
> >> Being able to do if $monitor::service includes(httpd) would also
be cool.
>
> > You didn''t answer my question.
>
> $monitor::service is used in multiple erb templates as an array.