This may be a dumb question, but here goes So I''m running on Puppet 3.1.1 on RHEL5, and i''ve been using Hiera since 2.5/2.6 ish and it''s been great!! I was reading up on Automatic Parameter Lookups and would love to use it for my modules. But I can''t seem to ever get Hiera/Puppet to load the value i''ve set in my yaml files. I feel like I must be missing something. I''ve worked my way through the docs, and am just not sure what I''m missing. I decided to use the 2.7 example, just to see what it did and noticed that this $puppetservertest = hiera(''puppet::puppetservertest'', ''test''), Doesn''t work, but this $puppetservertest = hiera(''puppetservertest'', ''test''), Does! I''m working on my puppet module, so I was expecting the lookup to grab the variable from my puppet.yaml file (which it does in the second example) My test puppet.yaml file is pretty simple, it looks like this # Parameters for Puppet Class --- puppetservertest: - ''puppet.example.com'' If anyone can shed some light on this it would be awesome! Thanks -a -- 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.
Brian Lalor
2013-Apr-18 20:42 UTC
Re: [Puppet Users] Hiera Automatic Parameter Lookup Question
When you use the hiera() function, you ate by definition not doing automatic param lookup. :-) whatever you put in for the first argument is the key that will be looked up via hiera verbatim. If you leave the class parameter without a default and instantiate it without a value, puppet will prefix the name of the class to the param name with double colons and use that as the lookup key in hiera. -- Brian Lalor blalor@bravo5.org On Apr 18, 2013, at 4:15 PM, Alaric <paxindustria@gmail.com> wrote:> This may be a dumb question, but here goes > > > So I''m running on Puppet 3.1.1 on RHEL5, and i''ve been using Hiera since 2.5/2.6 ish and it''s been great!! I was reading up on Automatic Parameter Lookups and would love to use it for my modules. But I can''t seem to ever get Hiera/Puppet to load the value i''ve set in my yaml files. I feel like I must be missing something. > > > I''ve worked my way through the docs, and am just not sure what I''m missing. I decided to use the 2.7 example, just to see what it did and noticed that this > > $puppetservertest = hiera(''puppet::puppetservertest'', ''test''), > > > Doesn''t work, > > but this > > $puppetservertest = hiera(''puppetservertest'', ''test''), > > Does! > > I''m working on my puppet module, so I was expecting the lookup to grab the variable from my puppet.yaml file (which it does in the second example) > > My test puppet.yaml file is pretty simple, it looks like this > > > # Parameters for Puppet Class > --- > puppetservertest: - ''puppet.example.com'' > > > If anyone can shed some light on this it would be awesome! > > Thanks > > -a > > -- > 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. > >-- 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.
jcbollinger
2013-Apr-19 13:34 UTC
Re: [Puppet Users] Hiera Automatic Parameter Lookup Question
On Thursday, April 18, 2013 3:42:32 PM UTC-5, blalor wrote:> > When you use the hiera() function, you ate by definition not doing > automatic param lookup. :-) whatever you put in for the first argument is > the key that will be looked up via hiera verbatim. If you leave the class > parameter without a default and instantiate it without a value, puppet will > prefix the name of the class to the param name with double colons and use > that as the lookup key in hiera. > >So, yes, the main issue here is that the keys in your hiera data files must match the ones by which Puppet attempts to look up the data. The keys are opaque to hiera, and the context of each lookup nearly so. If you want to lookup key ''puppet::puppetservertest'' then that key must appear in the data -- it is a different key from ''puppetservertest'', regardless of where the hiera() call appears. Moreover, I wanted to point out that, contrary to Brian''s implication, automated class parameter binding is independent of whether parameters have explicit default values. If you do not bind a parameter''s value via a class''s declaration (and you shouldn''t) then Puppet attempts to look up a value for it via hiera, regardless of whether an explicit default value is declared by the class. Only if the hiera lookup fails is an explicit default used. John -- 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.
Brian Lalor
2013-Apr-19 13:49 UTC
Re: [Puppet Users] Hiera Automatic Parameter Lookup Question
On Apr 19, 2013, at 9:34 AM, jcbollinger <John.Bollinger@stJude.org> wrote:> Moreover, I wanted to point out that, contrary to Brian''s implication, automated class parameter binding is independent of whether parameters have explicit default values. If you do not bind a parameter''s value via a class''s declaration (and you shouldn''t) then Puppet attempts to look up a value for it via hiera, regardless of whether an explicit default value is declared by the class. Only if the hiera lookup fails is an explicit default used.That''s kind of cool. class foo ( $bar => hiera(''baz'', ''bap''), ) { } So $bar will be set to "bap" only if foo::bar and baz are not found in Hiera, in that order? -- Brian Lalor blalor@bravo5.org -- 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.
jcbollinger
2013-Apr-22 13:59 UTC
Re: [Puppet Users] Hiera Automatic Parameter Lookup Question
On Friday, April 19, 2013 8:49:14 AM UTC-5, blalor wrote:> > On Apr 19, 2013, at 9:34 AM, jcbollinger <John.Bo...@stJude.org<javascript:>> > wrote: > > Moreover, I wanted to point out that, contrary to Brian''s implication, > automated class parameter binding is independent of whether parameters have > explicit default values. If you do not bind a parameter''s value via a > class''s declaration (and you shouldn''t) then Puppet attempts to look up a > value for it via hiera, regardless of whether an explicit default value is > declared by the class. Only if the hiera lookup fails is an explicit > default used. > > > That''s kind of cool. > > class foo ( > $bar => hiera(''baz'', ''bap''), > ) { } > > So $bar will be set to "bap" only if foo::bar and baz are not found in > Hiera, in that order? > >I had to study that for a minute to see what you meant, but yes, that is correct for Puppet 3. Puppet 2 will differ. Puppet 3 may perform both lookups even when foo::bar is found, however, even though in that case it doesn''t use the result of the ''baz'' lookup. That could be significant under some circumstances, such as when using an Hiera back-end that is expensive to call. John -- 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.