# expanding lists

**URL:** <https://forum.ansible.com/t/expanding-lists/17097>\
**Category:** Ansible Project\
**Created:** [December 18, 2014, 11:45am UTC](https://forum.ansible.com/t/expanding-lists/17097 "2014-12-18T11:45:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [December 18, 2014, 11:45am UTC](https://forum.ansible.com/t/expanding-lists/17097/1 "2014-12-18T11:45:35Z")

</div>

Hi,

I have a list of groups

admin:  
groups: [‘group-boapp-layout-A’, ‘group-boapp-layout-B’]

Each of these groups has a number of hosts as defined in the inventory

(note that this info needs to be global as opposed to per group\_vars/group-boapp-layout-A.yml so that it can be accessed by other groups)

[group-boapp-layout-A]  
ec2-test-boapp01  
ec2-test-boapp02

[group-boapp-layout-B]  
ec2-test-boapp03  
ec2-test-boapp04

[tier-boapp:children]  
group-boapp-layout-A  
group-boapp-layout-B

GROUPS Variables (“groups”):

---

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [December 18, 2014, 1:10pm UTC](https://forum.ansible.com/t/expanding-lists/17097/2 "2014-12-18T13:10:16Z")

</div>

A possible solution if I can’t expand the lists into one list is to define a different group of hosts specifically for the application. Though that seems messier

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 18, 2014, 2:54pm UTC](https://forum.ansible.com/t/expanding-lists/17097/3 "2014-12-18T14:54:18Z")

</div>

You have group theory filters like |union that can help with this.  
Note that with\_flattened was buggy in 1.8.1, should be fixed in 1.8.2.  
I would also avoid the - in names whenever possible, it creates issues  
with certain methods of access.

---

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [December 18, 2014, 2:58pm UTC](https://forum.ansible.com/t/expanding-lists/17097/4 "2014-12-18T14:58:52Z")

</div>

Hi,

Thanks for that. I have tried to avoid the “in” approach though I have found that the information about where things needs to live needs to be accessed from multiple tiers / groups

I.e apache configuration on the web tier needs to know the hosts that the application is configured on.

I’ll have a rethink of my approach as I do agree that it should be avoided if possible.

Interesting about 1.8.2. I’ll keep an eye on that. I was pretty sure it was doing what I was expecting prior to 1.8.1.

Many thanks

James
