# Group of groups

**URL:** <https://forum.ansible.com/t/group-of-groups/19000>\
**Category:** Ansible Project\
**Created:** [August 12, 2015, 6:13am UTC](https://forum.ansible.com/t/group-of-groups/19000 "2015-08-12T06:13:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![trupti\_mali](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@trupti\_mali](https://forum.ansible.com/u/trupti_mali)\
**Post date:** [August 12, 2015, 6:13am UTC](https://forum.ansible.com/t/group-of-groups/19000/1 "2015-08-12T06:13:07Z")

</div>

Hi I have a requirement to run the set of rules per group completely in silo and then consider next group of servers to run the same set of roles.

e.g.

my hosts file

[db1]  
1.2.3.4  
5.6.7.8

[db2]  
11.22.33.44  
55.66.77.88

[groupDB:children]  
db1  
db2

My playbook -

- hosts: groupDB  
roles:
- step1
- step2

What I want is to run step1, step2 for db1 for once and then run step1,step2 for db2 …either parallely or serially - that doesnt matter.

But in actual what happens is it runs step1 for each of the 4 nodes in db1,db2 then goes to step2.

Can you please suggest a solution to this?

Thx  
Trupti

---

<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:** [August 12, 2015, 1:21pm UTC](https://forum.ansible.com/t/group-of-groups/19000/2 "2015-08-12T13:21:05Z")

</div>

A few solutions:  
- use serial keyword  
- copy the play in same playbook, have first one target db1 hosts, 2nd  
target db2  
- make hosts: a parameter you pass from the command line, then call it  
for db1 and then for db2 hosts.

---

<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:** [August 12, 2015, 1:23pm UTC](https://forum.ansible.com/t/group-of-groups/19000/3 "2015-08-12T13:23:23Z")

</div>

Right now, your only option is to run that playbook separately, setting --limit to db1 and db2 respectively.

I have a similiar use case, where i deploy clusters, and want to serially run the deploy on each node of the cluster, whilst running all clusters in parallel.

So that would be:

- step/task 1 on all the first nodes in parallel
- step/task 2 on all the second nodes in parallel
- …

This is currently not possible in ansible up to 1.9. i am wondering if that could happen with a strategy plugin in v2, but this will probably need an update to the inventory code, allowing the executor to know about the concept of a ‘clustergroup’.

---

<div class="post-metadata">

**Author:** ![trupti\_mali](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@trupti\_mali](https://forum.ansible.com/u/trupti_mali)\
**Post date:** [August 12, 2015, 1:24pm UTC](https://forum.ansible.com/t/group-of-groups/19000/4 "2015-08-12T13:24:19Z")

</div>

Thanks for the response Brian. I was leaning towards 3rd option. But is there a way we can pass in list of hosts from command line.

---

<div class="post-metadata">

**Author:** ![trupti\_mali](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@trupti\_mali](https://forum.ansible.com/u/trupti_mali)\
**Post date:** [August 12, 2015, 1:26pm UTC](https://forum.ansible.com/t/group-of-groups/19000/5 "2015-08-12T13:26:16Z")

</div>

Hey Serge,  
Thanks. I read about limit as well. But does it work with groups of hosts? I saw examples of ips and some conditions.

---

<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:** [August 12, 2015, 1:27pm UTC](https://forum.ansible.com/t/group-of-groups/19000/6 "2015-08-12T13:27:02Z")

</div>

​yes, it basically accepts the same constructs as hosts: etc​
