[Puppet Users] Re: Hiera isn't merging hashes

2014-02-27 Thread paul . lewis
That explains a lot, thanks!

On Wednesday, February 26, 2014 10:08:27 PM UTC-5, Charlie Sharpsteen wrote:

 On Wednesday, February 26, 2014 2:19:23 PM UTC-8, paul@complex.comwrote:

 I have been doing some experimenting with Puppet + Hiera with some of my 
 hashes, but when it is going through my hierarchy it is returning whatever 
 hash it hits first and skipping the others.

 For my node 'sandbox1'

 sandbox.pp:

 node /^sandbox\d+/ {
   class { 'php':}
   notify { 'PHP hash':
 message = hiera('php::augeas',{})
   }
   $php_settings = hiera('php::augeas',{})
   create_resources('php::augeas',$php_settings)
 }



 The `hiera` lookup function only returns the first key it finds --- which 
 is the behavior you are observing. For hash merge lookup, you will need to 
 use the `hiera_hash` function in your manifest instead of `hiera`.

 For full details, see the docs on Hiera lookup functions:

 http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions

 Hope this helps!

 -Charlie


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/5a5d7c53-043f-4ab3-9f92-ee80d9e7ff1b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Hiera isn't merging hashes

2014-02-26 Thread paul . lewis
I currently have these versions of puppet related packages installed:

# yum list installed | grep puppet

facter.x86_64   1:1.7.3-1.el6  @puppetlabs-products
hiera.noarch1.3.1-1.el6@puppetlabs
puppet.noarch   3.3.1-1.el6@puppetlabs
puppet-dashboard.noarch 1.2.23-1.el6   @puppetlabs-products
puppet-server.noarch3.3.1-1.el6@puppetlabs
puppetdb.noarch 1.5.2-1.el6@puppetlabs
puppetdb-terminus.noarch1.5.2-1.el6@puppetlabs

I also have :merge_behavior set to deeper


On Wednesday, February 26, 2014 6:08:51 PM UTC-5, Andrew wrote:

 you need to use hiera 1.2 and enable deep merging
 On 26 Feb 2014 22:19, paul@complex.com javascript: wrote:

 I have been doing some experimenting with Puppet + Hiera with some of my 
 hashes, but when it is going through my hierarchy it is returning whatever 
 hash it hits first and skipping the others.

 For my node 'sandbox1'

 sandbox.pp:

 node /^sandbox\d+/ {
   class { 'php':}
   notify { 'PHP hash':
 message = hiera('php::augeas',{})
   }
   $php_settings = hiera('php::augeas',{})
   create_resources('php::augeas',$php_settings)
 }


 hiera.yaml:

 ---
 :backends:
   - json
 :json:
   :datadir: /etc/puppet/hiera
 :merge_behavior: deeper
 :hierarchy:
   - nodes/%{::hostname}
   - roles/%{::role}
   - provider/%{::provider}
   - provider/%{::provider}/virtual/virtual_%{::is_virtual}
   - common


 hiera/nodes/sandbox1.json:

 {
 php::augeas : {
 php-allow_url_fopen : {
 entry   : PHP/allow_url_fopen,
 value   : On
 }
 }
 }


 hiera/roles/sandbox.json:

 {
 php::augeas : {
 php-log_errors : {
 entry   : PHP/log_errors,
 value   : On
 }
 }
 } 


 hiera/common.json:

 {
 php::augeas : {
 php-date_timezone : {
 entry   : Date/date.timezone,
 value   : America/New_York
 },
 php-short_open_tag : {
 entry   : PHP/short_open_tag,
 value   : On
 },
 php-error_log : {
 entry   : PHP/error_log,
 value   : /var/log/php/php_error.log
 }
 }
 } 


 In this configuration, *only  php-allow_url_fopen **from the top-level 
 nodes hash is returned*. If I remove that nodes/sandbox1.json, it only 
 returns the php-log_errors from the next roles hiera level down. 
 Finally, if the nodes and roles json's are removed it will apply all three 
 from the common.json hash.

 I have tried both native and deeper merge behaviors with the same result. 
 The strangest thing is that the hiera command line tool on the master 
 returns the correct hash:

 # hiera -h php::augeas ::hostname=sandbox1 ::role=sandbox -c 
 /etc/puppet/hiera.yaml

 {php-date_timezone=
   {entry=Date/date.timezone, value=America/New_York},
  php-short_open_tag={entry=PHP/short_open_tag, value=On},
  php-error_log=
   {entry=PHP/error_log, value=/var/log/php/php_error.log},
  php-log_errors={entry=PHP/log_errors, value=On},
  php-allow_url_fopen={entry=PHP/allow_url_fopen, value=On}}


  -- 
 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...@googlegroups.com javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/puppet-users/96454179-6cd7-4c54-9ec2-2bf553e319a9%40googlegroups.com
 .
 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ddc1f9c0-8d30-43ad-856c-2fdf771f5b3e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Puppet Users] Three level hashes in ERB

2014-01-16 Thread paul . lewis
I have been trying to create a three level hash to dump into a template, 
but the deepest layer of the hash seems to not work.

My hash:

$clusters = {
'Default' = {
  '127.0.0.1:11211' = { 
'hostname' = '127.0.0.1', 
'port' = '11211'
  },
},
  }

My ERB template (modified for readability):
% @clusters.sort.map do |k,v| -%
  % if v.is_a?(Hash) -%
'%= k %'
% @clusters[k].sort.map do |ki, vi| -%
  % if vi.is_a?(Hash) -%
'%= ki %'
% @clusters[ki].sort.map do |kii, vii| -%
  % if vi and vi != '' -%
'%= kii %' = '%= vii %',
  % end -%
% end -%
  % end -%
% end -%
  % end -%
% end -%

For some reason that I can't quite figure out, the innermost hash throws 
a Detail: undefined method `sort' for nil:NilClass error. I assume if ki 
was not a hash, the if vi.us_a?(Hash) would have been false and skipped 
that sort.

What am I doing wrong here?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/da61d6e0-40bc-4dca-893a-717dcd44004b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.