Group of groups

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

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.

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

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.

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.

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