I'm configuring my environment via the following:
inventory.yml
all:
children:
production:
1.2.3.4
staging:
1.2.3.5
In group_vars/all.yml I'm setting up a hash of users which will be added in a playbook. I'd like to be able to add users specifically to group_vars/staging.yml that would be merged with the same setting in my group_vars/all.yml.
Is there a proper way to merge the hash or declare an inheritance in this case?
Best Answer
See DEFAULT_HASH_BEHAVIOUR. Quoting
For example, given the inventory and group_vars
The playbook
by default overrides the dictionaries. Gives (abridged)
When ANSIBLE_HASH_BEHAVIOUR is set to merge the dictionaries the playbook gives (abridged)
This setting will be deprecated in 2.13.
Quoting the Deprecated detail
Quoting the Deprecated alternatives
For example, rename the common users' dictionary to users_all
Then the filter combine merges the dictionaries
gives (abridged)