[Ansible 2.5] Question about with_dict and hash_behaviour = merge

According to this blog post: https://www.ansible.com/blog/loop-plays-past-present-future with_dict is going away. All my roles rely heavily on with_dict and hash_behaviour = merge merging to avoid configuring the same values over and over again. If I need to add or override a value, I just give it the same key in the correct vars file or on the command line.

As in:

roles/common/default.yml

champions: therock: "Yeah!" me: "Uh oh."

project/group_vars/web/main.yml

champions: me: "I win." them: "We lose."

project/host_vars/node1.yml (in web group)

champions: therock: "boom."

project/host_vars/node2.yml (in web group)

`
#champions just uses defaults.

`

So, node1 would look like:

champions: therock: "boom." me: "I win." them: "We lose."

node2:

champions: therock: "Yeah!" me: "I win." them: "We lose."

That lets me define common values in as few places as possible.

Is there a way to emulate using lookups?

Is there a better way to avoid defining common values in as few places as possible that I just haven’t seen yet?

What I’m trying to avoid is having a list of common, say iptable rules, configured in group_vars, but I have to modify or add just one of those rules a bit on a specific node. Using a list, or not merging hashes, would make me copy every single rule in the list from the group_vars file to the host_vars file. Otherwise I’d lose all but the one I modified or added.

Thanks.

With with_dict <- you are already using a lookup, `lookup("dict",
....`, all with_<lookup name> constructs ARE lookups.

Using a lookup or not, the hash_behaviour stays unchanged. Also there
is a filter dict2items that you might want to use instead of the
lookup.

So, replace:

     with_dict: "{{ champions }}"

with:

     loop: "{{ lookup('dict', champions }}"

?

That is one possibility, another:

loop: '{{champions|dict2items}}'