Some days I wonder why I even bother with puppet. --- classes: - datacentre::new_york - role::appserver - elements::tfel0 environment: production: parameters: < set key/value pairs here > class ldap { < do some stuff that behaves slightly differently between different data centers > } class role::appserver { include ldap } So, I wanted to set some variables in the datacentre::new_york class and be able to use them in the ldap class that was included from the role::appserver class. Obviously, this isn''t an easy thing to do in puppet. How can do I it? I didn''t want to set those data center variables in the external node because that''s just plain stupid. Every time I try and do something in puppet it bites me in the ass because the variable scoping just doesn''t make sense. Doug. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Does this do it? ${datacentre::new_york::VARIABLE_NAME} On Jun 24, 3:26 pm, Douglas Garstang <doug.garst...@gmail.com> wrote:> Some days I wonder why I even bother with puppet. > > --- > classes: > - datacentre::new_york > - role::appserver > - elements::tfel0 > environment: production: > parameters: > < set key/value pairs here > > > class ldap { > < do some stuff that behaves slightly differently between different > data centers > > > } > > class role::appserver { > include ldap > > } > > So, I wanted to set some variables in the datacentre::new_york class > and be able to use them in the ldap class that was included from the > role::appserver class. Obviously, this isn''t an easy thing to do in > puppet. How can do I it? I didn''t want to set those data center > variables in the external node because that''s just plain stupid. > > Every time I try and do something in puppet it bites me in the ass > because the variable scoping just doesn''t make sense. > > Doug.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Thomas A. McGonagle
2010-Jun-26 21:35 UTC
Re: [Puppet Users] Re: Yet more variable scoping pain.
Hey Doug, Chuck is right the way to model the ${datacenter::new_york::VARIABLE_NAME} variable is to do the following: class datacenter { } class datacenter::new_york inherits datacenter { $VARIABLE_NAME = foo } Then you can refer to that foo valuable with the fully qualified var name ${datacenter::new_york::VARIABLE_NAME) If you need to find that value in a template you will have to find it with the scope.lookupvar() erb function. i.e. <%scope.lookpvar("datacenter::new_york::VARIABLE_NAME") %> -Tom Thomas A. McGonagle tom@dataero.com Google Voice: 617-229-5185 On Fri, Jun 25, 2010 at 9:55 AM, Chuck <csschwe@gmail.com> wrote:> Does this do it? > > ${datacentre::new_york::VARIABLE_NAME} > > > On Jun 24, 3:26 pm, Douglas Garstang <doug.garst...@gmail.com> wrote: >> Some days I wonder why I even bother with puppet. >> >> --- >> classes: >> - datacentre::new_york >> - role::appserver >> - elements::tfel0 >> environment: production: >> parameters: >> < set key/value pairs here > >> >> class ldap { >> < do some stuff that behaves slightly differently between different >> data centers > >> >> } >> >> class role::appserver { >> include ldap >> >> } >> >> So, I wanted to set some variables in the datacentre::new_york class >> and be able to use them in the ldap class that was included from the >> role::appserver class. Obviously, this isn''t an easy thing to do in >> puppet. How can do I it? I didn''t want to set those data center >> variables in the external node because that''s just plain stupid. >> >> Every time I try and do something in puppet it bites me in the ass >> because the variable scoping just doesn''t make sense. >> >> Doug. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Douglas Garstang
2010-Jun-26 22:05 UTC
Re: [Puppet Users] Re: Yet more variable scoping pain.
On Sat, Jun 26, 2010 at 2:35 PM, Thomas A. McGonagle <tom@dataero.com> wrote:> Hey Doug, > Chuck is right the way to model the > ${datacenter::new_york::VARIABLE_NAME} variable is to do the following: > > class datacenter { } > class datacenter::new_york inherits datacenter { > $VARIABLE_NAME = foo > } > Then you can refer to that foo valuable with the fully qualified var > name ${datacenter::new_york::VARIABLE_NAME) > > If you need to find that value in a template you will have to find it > with the scope.lookupvar() erb function. i.e. <%> scope.lookpvar("datacenter::new_york::VARIABLE_NAME") %> > -TomThanks. Does it have to inherit? I think I''ve fully qualified the variable in the past an it''s worked when I''ve just used an include directive. A few days ago however, I also got a weird error where puppet said that the variable had not been defined yet, so it couldn''t be used (even though it had been defined). I tell ya... variable scoping in puppet it''s biggest downfall and pain point imho. Doug. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> I tell ya... variable scoping in puppet it''s biggest downfall and pain > point imho.I disagree. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwmjIIACgkQbwltcAfKi3/ZCgCeO45VlC38Sto7DOKIUStnuhuU tcAAn24csdqb8Tj8d2mIc1LdBK8E4PNg =SXQT -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Douglas Garstang
2010-Jun-27 06:05 UTC
Re: [Puppet Users] Re: Yet more variable scoping pain.
On Sat, Jun 26, 2010 at 4:25 PM, Peter Meier <peter.meier@immerda.ch> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > >> I tell ya... variable scoping in puppet it''s biggest downfall and pain >> point imho. > > I disagree.And I disagree with you. Not being able to do this is _REALLY_ annoying... class facility::sanJose inherits facility::base { $ldap_server = "ldap.sjc.xxx.com" } class ldap::client { < do something with $ldap_server > } node ''node1.sjc.xxx.com'' { include facility::sanJose include ldap::client } Doug. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1>> I disagree. > > And I disagree with you. > > Not being able to do this is _REALLY_ annoying...no, it is absolutely right that this isn''t possible. Actually, we would have a lot more pain if this would be possible. cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwnp3kACgkQbwltcAfKi39yogCfexT5vqG+Llardua0GUPEH/fb S6gAn0aFw17Q/YyQtb0Qsz/8umBac5At =Rgk6 -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Douglas Garstang
2010-Jun-27 19:34 UTC
Re: [Puppet Users] Re: Yet more variable scoping pain.
On Sun, Jun 27, 2010 at 12:33 PM, Peter Meier <peter.meier@immerda.ch> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > >>> I disagree. >> >> And I disagree with you. >> >> Not being able to do this is _REALLY_ annoying... > > no, it is absolutely right that this isn''t possible. Actually, we would > have a lot more pain if this would be possible.Would love to see your workaround Pete... -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.