Hash / Array Merging

asked 2017-04-17 06:25:40 -0600

puser gravatar image

I have data in module that uses lookup options to merge hashes together wherever they are found within my hiera hierarchy.

https://docs.puppet.com/hiera/3.3/loo... is the link to the lookup options that I am using.

I have a hash in hiera in the format:

rules:
'/tmp':
  options: 'R'
  daystokeep: '5'
  regex: '*'

Then elsewhere I have a hash elsewhere in my hierarchy like:

'/var/log':
  options: 'R'
  daystokeep: '5'
  regex: '*'

These merge correctly using the following in my module.yaml file.

  rules:
    merge:
     strategy: deep
     merge_hash_arrays: true

The problem is that if I want to have the same key in my hash, the hash breaks and only takes one of the two values, for example if I added the following:

rules:
'/tmp':
  options: ''
  daystokeep: '365'
  regex: '*.log'

It is different than the /tmp above however the key of the hash is the same and so they do not merge correctly.

Is there a way to create a hash with non-unique keys? Is there a way to create a hash of arrays that will also do a deep merge?

Any feedback and /or examples are appreciated.

thanks,

edit retag flag offensive close merge delete