Lars Francke
2012-Feb-25 14:08 UTC
[Puppet Users] Hiera Puppet backend - search order question
Hi! I''m testing Hiera for the first time and so far it is very pleasant. I''m looking very much forward to it being integrated into Puppet. So far I''ve got one question: I have a class ssh::server::install which is getting a parameter from Hiera. I''m using the yaml and puppet backends. I also have a class ssh::server::data. The puppet backend doesn''t look in this class though: debug: importing ''/home/lfrancke/puppet/modules/ssh/manifests/server/data.pp'' in environment production debug: importing ''/home/lfrancke/puppet/modules/ssh/manifests/data.pp'' in environment production debug: hiera(): Looking for data in ssh::server::install::data debug: hiera(): Looking for data in ssh::data I had hoped it would look through all parent namespaces: 1) ssh::server::install::data 2) ssh::server::data 3) ssh::data Is this intended behavior or worth a feature request? I''ve moved my configuration from ssh::data to ssh::server::data to separate it from the client configuration. It''s not a big deal but it seems like a minor inconsistency to me. Or even a bug because it seems to import the correct file (/server/data.pp)? Thanks, Lars -- 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.
Lars Francke
2012-Mar-23 00:32 UTC
[Puppet Users] Re: Hiera Puppet backend - search order question
I ran into the same problem again: define tmp::register { $foo = hiera(''foo''} class tmp::bar::foo { tmp::register { ''foo'': } } class tmp::data { $foo = ''foo'' } All of these files in their proper locations but hiera complains: debug: hiera(): Looking up foo in Puppet backend debug: hiera(): Looking for data in data::common debug: hiera(): Looking for data in foo::data err: Could not find data item foo in any Hiera data file and no default supplied at /puppet/modules/tmp/manifests/register.pp:1 on node slave1.local So it looked in data::common which is fine and then only in foo::data. I would have expected a lookup in tmp::data too. This is similar to what I asked before:> So far I''ve got one question: I have a class ssh::server::install > which is getting a parameter from Hiera. I''m using the yaml and puppet > backends. I also have a class ssh::server::data. > > The puppet backend doesn''t look in this class though: > debug: importing > ''/home/lfrancke/puppet/modules/ssh/manifests/server/data.pp'' in > environment production > debug: importing ''/home/lfrancke/puppet/modules/ssh/manifests/data.pp'' > in environment production > debug: hiera(): Looking for data in ssh::server::install::data > debug: hiera(): Looking for data in ssh::data > > I had hoped it would look through all parent namespaces: > > 1) ssh::server::install::data > 2) ssh::server::data > 3) ssh::data > > Is this intended behavior or worth a feature request? > > I''ve moved my configuration from ssh::data to ssh::server::data to > separate it from the client configuration. > > It''s not a big deal but it seems like a minor inconsistency to me. Or > even a bug because it seems to import the correct file > (/server/data.pp)?Any help would be greatly appreciated. Cheers, Lars -- 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.
Lars Francke
2012-Mar-23 01:41 UTC
[Puppet Users] Re: Hiera Puppet backend - search order question
I''ve looked at the puppet_backend.rb now and that explains the behavior I''m seeing (unsurprisingly ;-) ) Hiera in Defined Resource Types: It''s using the calling class and calling module to calculate the places it looks for its data. For defines though this is not the path where the define itself was defined (e.g. tmp::register) but the name it was given when it was declared (e.g. foo). That makes hiera in defines pretty useless in my opinion but perhaps I''m missing a important thing? And for my first mail: It doesn''t do any traversing of namespaces but only calling_class::data_class calling_module::data_class (in addition to the hierarchy as defined in hiera.yaml and a manual override) I have created a small test module to demonstrate the behaviour: https://github.com/lfrancke/puppet-hiera-lookuptest I''ve annotated the two config.pp classes with runtime information. Are there any plans on changing the lookup behavior in the future or is this fixed? Cheers, Lars -- 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.
Nan Liu
2012-Mar-23 04:24 UTC
Re: [Puppet Users] Re: Hiera Puppet backend - search order question
On Thu, Mar 22, 2012 at 6:41 PM, Lars Francke <lars.francke@gmail.com> wrote:> I''ve looked at the puppet_backend.rb now and that explains the > behavior I''m seeing (unsurprisingly ;-) ) > > Hiera in Defined Resource Types: > It''s using the calling class and calling module to calculate the > places it looks for its data. For defines though this is not the path > where the define itself was defined (e.g. tmp::register) but the name > it was given when it was declared (e.g. foo). That makes hiera in > defines pretty useless in my opinion but perhaps I''m missing a > important thing?Just include a local data class. class staging::param { $path = hiera(''staging_path'', ''/tmp'') } define staging::file { include staging::param file { "${staging::param::path}/${name}": ... } }> And for my first mail: It doesn''t do any traversing of namespaces but only > calling_class::data_class > calling_module::data_class > (in addition to the hierarchy as defined in hiera.yaml and a manual override) > > I have created a small test module to demonstrate the behaviour: > https://github.com/lfrancke/puppet-hiera-lookuptest I''ve annotated the > two config.pp classes with runtime information. > > Are there any plans on changing the lookup behavior in the future or > is this fixed?I think it makes more sense for define types to use the caller_module data than the module_name data. Nan -- 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.
Lars Francke
2012-Mar-23 16:26 UTC
Re: [Puppet Users] Re: Hiera Puppet backend - search order question
Hi Nan and thanks for your reply,>> Hiera in Defined Resource Types: >> It''s using the calling class and calling module to calculate the >> places it looks for its data. For defines though this is not the path >> where the define itself was defined (e.g. tmp::register) but the name >> it was given when it was declared (e.g. foo). That makes hiera in >> defines pretty useless in my opinion but perhaps I''m missing a >> important thing? > > Just include a local data classThat''s just what I''m trying to get away from by using Hiera but there''s probably no way around for now.>> And for my first mail: It doesn''t do any traversing of namespaces but only >> calling_class::data_class >> calling_module::data_class >> (in addition to the hierarchy as defined in hiera.yaml and a manual override) >> >> I have created a small test module to demonstrate the behaviour: >> https://github.com/lfrancke/puppet-hiera-lookuptest I''ve annotated the >> two config.pp classes with runtime information. >> >> Are there any plans on changing the lookup behavior in the future or >> is this fixed? > > I think it makes more sense for define types to use the caller_module > data than the module_name data.Well that''s what it does right now, only problem is that caller_module is equal to its namevar/title for defined resources while normal classes use their fullly qualified name. Any opinions on my second question? (i.e. should normal classes traverse up the namespace to look for data classes) Cheers, Lars -- 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.
Markus Falb
2012-Apr-13 20:50 UTC
Re: [Puppet Users] Re: Hiera Puppet backend - search order question
On 23.3.2012 02:41, Lars Francke wrote:> Hiera in Defined Resource Types: > It''s using the calling class and calling module to calculate the > places it looks for its data. For defines though this is not the path > where the define itself was defined (e.g. tmp::register) but the name > it was given when it was declared (e.g. foo). That makes hiera in > defines pretty useless in my opinion but perhaps I''m missing a > important thing?I try do understand the implications of this: class x::foo { $x = hiera(''bar'') } # is not related with class foo # is not related with define bar define y::foo () { $y = hiera(''bar'') } # is not related with class foo # is not related with define foo define z::bar () { $z = hiera(''bar'') } include x::foo y::foo { ''foo'': } z::bar { ''foo'': } Then the defines would get the value intended for the foo class if $calling_class is used in hiera.conf or if foo::data exists. That would mean that I cannot use hiera for defines. But how am I supposed to get at my data then? -- Kind Regards, Markus Falb