Hello, I have the following in common.yaml: apache: mpm: worker If I do a "manual" lookup with the hiera command I get the proper result: hiera --config /etc/puppet/hiera.yaml apache {"mpm"=>"worker"} However, when trying to get the apache hash in a manifest, it appears to be returned as a flattened string. I am using this notify statement in the manifest: $apache = hiera(''apache'') notify { "Hiera is: ${apache}": } And I get this returned: Notify[Hiera is: mpmworker] The same thing is returned when I used hiera_hash. Interestingly enough, when I used hiera_array I get this error message: Hiera type mismatch: expected Array and got Hash Am I seeing some sort of bug or am I doing something wrong? Puppet version: 2.7.18 Hiera version: 1.0.0-0.1rc4 Puppet-Hiera version: 1.0.0-0.1rc3 Thanks, Jarod -- 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/-/VmGS4fBuskgJ. 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.
Sorry, I should explained my issue: class apache ( $apache = hiera_hash(''apache''), $mpm = $apache[''mpm''], ) This code will produce the following error: Could not retrieve catalog from remote server: Error 400 on SERVER: apache is not an hash or array when accessing it with mpm If I do not try to set mpm inside the class definition but inside the manifest it will work: class apache ( $apache = hiera_hash(''apache''), ) { $mpm = $apache[''mpm''] notify { "Hiera is: ${mpm}": } Again am I seeing a bug or is this not how I should be doing things? Jarod On Wednesday, August 22, 2012 9:39:46 PM UTC-4, Jarod Watkins wrote:> > Hello, > I have the following in common.yaml: > > apache: > mpm: worker > > If I do a "manual" lookup with the hiera command I get the proper result: > > hiera --config /etc/puppet/hiera.yaml apache > {"mpm"=>"worker"} > > However, when trying to get the apache hash in a manifest, it appears to > be returned as a flattened string. I am using this notify statement in the > manifest: > > $apache = hiera(''apache'') > notify { "Hiera is: ${apache}": } > > And I get this returned: > > Notify[Hiera is: mpmworker] > > The same thing is returned when I used hiera_hash. Interestingly enough, > when I used hiera_array I get this error message: > > Hiera type mismatch: expected Array and got Hash > > Am I seeing some sort of bug or am I doing something wrong? > > Puppet version: 2.7.18 > Hiera version: 1.0.0-0.1rc4 > Puppet-Hiera version: 1.0.0-0.1rc3 > > Thanks, > Jarod >-- 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/-/ZTOWuA1Q69sJ. 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.
On Wednesday, August 22, 2012 9:22:04 PM UTC-5, Jarod Watkins wrote:> > Sorry, I should explained my issue: > > class apache ( > $apache = hiera_hash(''apache''), > $mpm = $apache[''mpm''], > ) > > This code will produce the following error: > > Could not retrieve catalog from remote server: Error 400 on SERVER: apache > is not an hash or array when accessing it with mpm > > If I do not try to set mpm inside the class definition but inside the > manifest it will work: > > class apache ( > $apache = hiera_hash(''apache''), > ) { > > $mpm = $apache[''mpm''] > notify { "Hiera is: ${mpm}": } > > Again am I seeing a bug or is this not how I should be doing things? >You should be using the plain hiera() function instead of hiera_hash(). The latter is for collecting values of the same key from multiple levels of your environment, and returning the combined result as a hash (level => value, IIRC). You just want the value assigned to key ''apache''; that the value happens to be a hash is irrelevant. 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/-/_mkKGzZ-4rsJ. 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.