group_vars on many groups ?

Hello !

I somehow need to

  • assign applications to groups of hosts
  • have a host in several groups in the platform
  • get the list of deployed applications in the platform
  • be able to get the list of hosts with the application.

I tried like that :

I’m trying to have a variable (dokku_apps) defined for multiple groups.
depending on the target server (testing, prod, and so on), a single host can use many groups or only one.

the idea is that a group should configure some dokku apps. so if a host is in many groups it should configure dokku apps specific to each of its group

my problem is that when a host is in many groups, the dokku_apps (configured in group_vars) is only from a single group (the latest i think) and is not merged (as expected from documentation)

I’m also using this list (dokku_apps) to configure varnish.

How can i achieve that ?

​Given that variables are merged according to group priorities, and there
is no some default way to add-up some lists, this is hard to achive
cleanly.​

A workaround might be to put this data in dictionaries, and enable dict
merging in ansible.cfg

TBH, I never found a clean wat to do this kind of construct. It should be
something we want to enable when revamping inventory things.