I am trying to read a key present in multiple hiera files and merge the values. My hiera file contains:
hierarchy:
- name: "Per-env secrets"
paths:
- "puppet/hiera/dict-1.yaml"
- "puppet/hiera/dict-2.yaml"
and My puppet script contains:
lookup(dictionaries,Hash).each |String $keyDico, Hash $valueDico| {
notify{"The value of dictionary is: ${keyDico}": }
The key 'dictionaries' is present in both dict-1.yaml and dict-2.yaml. However, It always reads and prints the Key from the first matched hiera file.
I tried changing 'Hash' in lookup function's argument to 'Unique' or 'Deep'. But it didn't work.
Getting error: Error: Evaluation Error: Resource type not found: Deep
and Error: Evaluation Error: Resource type not found: Unique
Is there any way to achieve this?
Thanks in advance.
If you look at the docs for specifying merge behaviours ( ref ), you can see that you need to specify the optional third argument to lookup
, and you are getting that error because "unique" is being interpreted as the data type.
Try either:
lookup(dictionaries, Hash, 'unique')
or
lookup(dictionaries, Hash, {'strategy' => 'unique'})
according to whichever you find more readable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.