Hi. I have a dilemma. So far I''ve used this kind of syntax: class foo ( $var1 = $foo::params::var1 $var2 = $foo::params::var2 $var3 = $foo::params::var3 ){ ... some code .. } but, I''ve seen also this kind of usage: class foo ( $var1 = $::foo::params::var1 $var2 = $::foo::params::var2 $var3 = $::foo::params::var3 ){ ... some code .. } So, what''s up with forcing the root scope for the default values of class params? Is this a better way of writing a module? What do you think is more "by the book"? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
David Schmitt
2013-Mar-08 07:44 UTC
Re: [Puppet Users] Parametrized classes and scope dilemma
On 2013-03-07 22:14, Jakov Sosic wrote:> Hi. > > I have a dilemma. > > So far I''ve used this kind of syntax: > > class foo ( > $var1 = $foo::params::var1 > $var2 = $foo::params::var2 > $var3 = $foo::params::var3 > ){ > ... > some code > .. > } > > but, I''ve seen also this kind of usage: > > > class foo ( > $var1 = $::foo::params::var1 > $var2 = $::foo::params::var2 > $var3 = $::foo::params::var3 > ){ > ... > some code > .. > } > > > So, what''s up with forcing the root scope for the default values of > class params? Is this a better way of writing a module? What do you > think is more "by the book"?The latter is what you want to say. The former is a legitimate shortcut until you have a class foo::foo. Then you''re welcome to a world of pain. Best Regards, David -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Nick Fagerlund
2013-Mar-08 22:42 UTC
[Puppet Users] Re: Parametrized classes and scope dilemma
It''s defensive coding around a long-standing unwanted behavior of Puppet. See bug http://projects.puppetlabs.com/issues/2053 More information and explanation here: http://docs.puppetlabs.com/puppet/latest/reference/lang_namespaces.html#relative-name-lookup-and-incorrect-name-resolution David''s comment is right in the general sense, but in the specific sense, you''d only run into a problem if you had both: - class foo::params - class foo::foo::params ...in which case you''d get the wrong one unless you forced top namespace. But since you''ll generally only have one params class per module, you''re generally fine. On Thursday, March 7, 2013 1:14:07 PM UTC-8, Jakov Sosic wrote:> > Hi. > > I have a dilemma. > > So far I''ve used this kind of syntax: > > class foo ( > $var1 = $foo::params::var1 > $var2 = $foo::params::var2 > $var3 = $foo::params::var3 > ){ > ... > some code > .. > } > > but, I''ve seen also this kind of usage: > > > class foo ( > $var1 = $::foo::params::var1 > $var2 = $::foo::params::var2 > $var3 = $::foo::params::var3 > ){ > ... > some code > .. > } > > > So, what''s up with forcing the root scope for the default values of > class params? Is this a better way of writing a module? What do you > think is more "by the book"? >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.