# group\_vars on many groups ?

**URL:** <https://forum.ansible.com/t/group-vars-on-many-groups/18663>\
**Category:** Ansible Project\
**Created:** [July 2, 2015, 3:05pm UTC](https://forum.ansible.com/t/group-vars-on-many-groups/18663 "2015-07-02T15:05:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charly\_Koza](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Charly\_Koza](https://forum.ansible.com/u/Charly_Koza)\
**Post date:** [July 2, 2015, 3:05pm UTC](https://forum.ansible.com/t/group-vars-on-many-groups/18663/1 "2015-07-02T15:05:13Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [July 5, 2015, 3:54pm UTC](https://forum.ansible.com/t/group-vars-on-many-groups/18663/2 "2015-07-05T15:54:29Z")

</div>

​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.
