Un-Unique Keys in Hiera Hash

asked 2017-04-14 08:32:06 -0500

puser gravatar image

updated 2017-04-14 10:10:09 -0500

I have data in hiera that is structured to purge directories of specific files based on the path, age, and name.

I have a data structure like the following:

rules:
 '/tmp':
   daystokeep: 5
   wildcard: '*.log'

The problem is that if I want to add another rule for /tmp, I cannot because the names would be the same like:

rules:
 '/tmp':
   daystokeep: 5
   wildcard: '*.log'
 '/tmp':
   daystokeep: 2
   wildcard: '*.txt'

Hiera only takes the second value. Is there a struct that I could create that would fullfill the requirements with this data structure?

thanks,

EDIT

Fixed with:

rules:
 - path: '/tmp':
   daystokeep: 5
   wildcard: '*.log'
 - path: '/tmp':
   daystokeep: 2
   wildcard: '*.txt'

I don't know how this worked ^ What data structure is that? An array with hashes?

edit retag flag offensive close merge delete

Comments

1

That is an array of hashes in YAML. I can't help you determine *why* that change worked unless you share the relevant Puppet code.

natemccurdy gravatar imagenatemccurdy ( 2017-04-16 23:30:55 -0500 )edit