Vaidas Jablonskis
2012-Dec-02 16:15 UTC
[Puppet Users] Hiera tool and hiera-puppet returns different data
Hi People, I came across an issue where hiera command line tool returns a different data to what puppet3.0 builtin hiera does. When I say different data, I mean hiera tool returns an array of items collected throughout the hierarchy, while hiera_array() called from within a manifest returns an array of items from the very top level of hierarchy. Here is my setup example: ----- node1.example.local.yaml: foo::conf: - ''node_specific = foo'' - ''node_specific2 = foo2'' common.yaml: foo::conf: - ''common = foo'' - ''common2 = foo2'' ----- That''s what I get by running hiera tool on the puppet master: # hiera -c /etc/puppet/hiera.yaml -a foo::conf environment=''development'' fqdn=''node1.example.local'' ["node_specific = foo", "node_specific2 = foo2", "common = foo", "common2 = foo2"] From within the manifest, I use as a parameter: $conf = hiera_array(''foo::conf'') and then I have a template which creates a file on a node: <% conf.each do |item| -%> <%= item %> <% end -%> .. so what this template create is the following content of a file on node1: node_specific = foo node_specific2 = foo2 The node is in development environment. What am I doing wrong? Is this some kind of bug or intentional behavior of puppet and hiera? Thanks, Vaidas -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/PgUdDVAFw9kJ. 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.
Vaidas Jablonskis
2012-Dec-02 16:36 UTC
[Puppet Users] Re: Hiera tool and hiera-puppet returns different data
Adding my hiera.yaml content: # cat /etc/puppet/hiera.yaml --- :hierarchy: - %{environment}/nodes/%{fqdn} - %{environment}/roles/%{role} - %{environment}/common :backends: - yaml #- puppet :yaml: :datadir: ''/etc/puppet/hieradata'' :puppet: :datasource: ''data'' -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/qn5U7yIuubgJ. 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.
Vaidas Jablonskis
2012-Dec-02 17:46 UTC
[Puppet Users] Re: Hiera tool and hiera-puppet returns different data
Opened up an issue report: http://projects.puppetlabs.com/issues/17896 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/a96yvzSdAWYJ. 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.
Vaidas Jablonskis
2012-Dec-02 21:03 UTC
[Puppet Users] Re: Hiera tool and hiera-puppet returns different data
See my issue report, I updated it with my finding. It seems to be a bug. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/QHF75o_kCMIJ. 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.
Vaidas Jablonskis
2012-Dec-02 22:19 UTC
[Puppet Users] Re: Hiera tool and hiera-puppet returns different data
wrong. Thanks to reidmv and Volcane from #puppet @freenode for explaining this to me. There is no easy way to use hiera_hash() or hiera_array() using the built-on hiera() lookup. The easiest workaround in my case is to do something like this: # class class foo( $configuration = hiera_array(''foo::conf'', undef) ) {...} # template <% configuration.each do |item| -%> <%= item %> <% end -%> # cat nodes/node1.example.local.yaml: foo::conf: - ''node_specific = foo'' - ''node_specific2 = foo2'' # cat common.yaml: foo::conf: - ''common = foo'' - ''common2 = foo2'' On Sunday, 2 December 2012 21:03:49 UTC, Vaidas Jablonskis wrote:> > See my issue report, I updated it with my finding. It seems to be a bug.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/49e8Z2cZLsgJ. 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.
jcbollinger
2012-Dec-03 15:37 UTC
[Puppet Users] Re: Hiera tool and hiera-puppet returns different data
On Sunday, December 2, 2012 4:19:24 PM UTC-6, Vaidas Jablonskis wrote:> > wrong. > > Thanks to reidmv and Volcane from #puppet @freenode for explaining this to > me. > > There is no easy way to use hiera_hash() or hiera_array() using the > built-on hiera() lookup. > > The easiest workaround in my case is to do something like this: > > > > # class > class foo( > $configuration = hiera_array(''foo::conf'', undef) > ) {...} > > > # template > <% configuration.each do |item| -%> > <%= item %> > <% end -%> > > > # cat nodes/node1.example.local.yaml: > foo::conf: > - ''node_specific = foo'' > - ''node_specific2 = foo2'' > > # cat common.yaml: > foo::conf: > - ''common = foo'' > - ''common2 = foo2'' > >So, yes, if you want the functionality of hiera_array() or hiera_hash() then you must call those functions. Class parameter auto-lookup uses the hiera() function. Personally, I would recommend always calling hiera(), hiera_array(), or hiera_hash() explicitly instead of parametrizing your classes and relying on autolookup. It is clearer, and if you want compatibility with Puppet 2.7 then it''s essential. It also removes the false distinction that your classes appear to have if they need to use hiera_array() or hiera_hash() for some data, but plain hiera() for others. Inasmuch as you should always *declare* classes via the ''include'' or ''require'' function anyway (not via the parametrized style), defining formal class parameters gains you little of consequence. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/G7adwu67XlIJ. 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.