Hi
I am in the process of migrating v3 hiera.yaml to v5 and I would like all hash merges to merge 'deep' by default, the same way :merge_behavior: deeper in v3 parameter provides.
I can't seem to find an easy way to do this after reading the docs - I understand lookup_options: need to be set, however it requires class parameter to be specified. I tried using regex as below and adding it to common.yaml however it does not produce the desired result (it works ok if I specify the hash name explicitly, however I am looking to expand this behaviour to all lookups, if possible).
Is there an easy way to just migrate :merge_behavior: deeper to v5?
Thanks,
D
lookup_options:
'.*':
merge:
strategy: deep
Depends on what you mean. The 'deep' in hiera 5 is the same as 'deeper'
in hiera 3. It just works.
If you mean that all keys should lookup with strategy 'deep' then you
use the lookup_options to set that for all keys.
Of course I always have alternatives like replacing all hiera_hash() functions in my manifests with lookup() with correct options however this is a fair bit of work and I wanted to make sure first I absolutely cannot achieve this by tweaking Hiera options.
$hash_merge_behavior = lookup(':merge_behavior', String, 'unique', 'hash')
# original
$my_hash = hiera_hash('key', { ... })
# updated
$my_hash = lookup('key', Hash, $::hash_merge_behavior, {...})
$hash_merge_behavior = lookup(':merge_behavior', String, 'unique', 'hash')
$hash_merge_behavior = lookup(':merge_behavior', String, 'first', 'hash')