Group of groups

44 views
Skip to first unread message

trupti mali

unread,
Aug 12, 2015, 2:13:08 AM8/12/15
to Ansible Project
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

Brian Coca

unread,
Aug 12, 2015, 9:21:11 AM8/12/15
to Ansible Project
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.
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d9c0932d-b985-43b5-b76b-d48076e330c5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Serge van Ginderachter

unread,
Aug 12, 2015, 9:24:00 AM8/12/15
to ansible...@googlegroups.com
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'.



--

trupti mali

unread,
Aug 12, 2015, 9:24:19 AM8/12/15
to Ansible Project
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. 

trupti mali

unread,
Aug 12, 2015, 9:26:16 AM8/12/15
to Ansible Project
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.

Serge van Ginderachter

unread,
Aug 12, 2015, 9:27:32 AM8/12/15
to ansible...@googlegroups.com

On 12 August 2015 at 15:26, trupti mali <trupt...@gmail.com> wrote:
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​
Reply all
Reply to author
Forward
0 new messages