In ansible.cfg, under the '[defaults]' section, you can put 'hash_behavior = merge'. I think this is new as of the pending 1.1 release, so you'll need a gift checkout.
See <https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg> for an example config file.
Excerpts from seb.stark's message of 2013-03-25 10:17:18 -0400:
Thanks for noting! Is this also possible for lists?
I don't believe so.
Nope, there's no good way to tell what behavior you would want with lists.
My use case is a packages variable in group_vars/all that I want to append to in group_vars/<group> and host_vars/<host>. So far I use two more variables (group_packages and host_packages), that default to and separate actions for using them.
But maybe there is already a better way to do this?
Your approach would work, though if hosts were in more than one group,
that doesn't work so much.
Generally I find the purpose of plays though to bind hosts to roles,
so the individual roles should contain the package lists.
I would not try to store everything in variables that way.
In fact, you should almost never have host specific variables related
to behavior -- networking and hardware configurations yes, but very
seldom behavior.
Good point. I already noticed my system isn’t working well because I have roles that add yet more packages to individual hosts. In fact, those explicit package lists are the only contents of my host_vars/* files and I should really get rid of them. Thanks for the heads up!