It's not a mistake. According to docs about the priority of a variable, you should not define a variable in several places and try to simplify it. Michael DeHaan (Ansible lead dev) answered a similar question on this topic:
As a rule, I find the goal of games, but to bind hosts to roles, so individual roles should contain list of packages.
I would use roles as this is a bit cleaner IMO.
If you really want (and this is NOT the recommended way), you can set the hash_behaviour option in the ansible.cfg file:
[defaults] hash_behaviour = merge
This will merge the two values ββwhen overriding the hash (dict) instead of replacing the old value with the new one. However, this does not work in lists, so you need to create a hash of lists, for example:
group_vars / all / package.yml:
packages: all: [pkg1, pkg2]
group_vars / servers / package.yml:
packages: servers: [pkg3, pkg4]
The cycle, although the textbook is a bit more complicated.
source share