is there any documentation on why this was deprecated? This breaks close to all of my ansible roles as well as it results in a full rewrite of the inventory for all organisations where I use ansible. I’m using “hash_behaviour = merge”
Most of my inventory resides in dictionaries wich depend on getting merged on the inventory level. For example I have a “nginx” dictionary with “vhost” key in it. I depend on all vhosts from all groups a host is in to get merged. I have something like this for nearly all my roles. I could rewrite my playbook to merge all dictionaries with a group prefix using the combine filter (or similar workarounds) prior to including any roles. But I think this results in much less readable playbooks and it definitly results in multiple person days of work…
The other option I look into is writing a custom inventory plugin to always deep merge dictionaries with the same name, kind of resulting in the current behavior.
Anyone else with a similar problem or some insight on why this was changed? I was realy taken by surprise when I saw this message. If i could choose, I’d prefere deepmerge as default over “replace”. It results in better split up inventories and more seperation of data in multiple files. “Replace” always seemed kind of useless and less useable to me.
I’ll second ND that the hash_behavior option of “merge” is more usable in my situation - I have hashes of information that get built up in the playbook (one piece sets defaults for a location (i.e. “North America” vs “Europe” vs “Asia”), then a later part sets defaults for different datacenters, and later a specific subnet might over-ride other settings. This way I could have all my European systems default to using settings that applied to the entire zone, but my servers in different datacenters would get settings specific there (i.e. a Git or NTP server, etc), and individual subnets might have different NTP servers but still use the datacenters’ Git server.
Merging hashes was a big win for this project. Sadly, we don’t have a “single source of truth”, so we had to use multiple Ansible variable files to build up our “truth” and merging them with each other. Our inventories were not the source of truth with all the information needed. Without an external CMDB that could take into account the location, datacenter, and subnet (to name a few constraints), getting the data consistent would have been impossible with Ansible.
I’m not a programmer to the level that I can determine a better way to address this in Ansible, but I’m hoping someone will work through a way to merge them together and the hash merge behavior can be exposed again.
I can see how this feature would work by overriding nested items by merging.
But now I think of it again, I had trouble if I wanted to remove/unset
a nested item later?
IMHO it's this sort of corner cases that make things difficult.