Grouping of serial tasks

33 views
Skip to first unread message

Abhishek Mukherjee

unread,
May 13, 2015, 7:39:30 AM5/13/15
to ansible...@googlegroups.com
Sorry i'm relatively new to ansible so I may be asking a very obvious question :(. Basically my organization has servers in two tiers, and within those tiers there are groups. What I'm trying to make happen is an ansible syntax that will restart all of the one tier in parallel, but will only be restart one server in each group at a time. So, for example, the primary tiers are frontends and backends. Within backends we have serviceA, serviceB, and serviceC. Each of those will have multiple actual hosts tied to it which I'll call svcA1, svcA2, svcB1, svcB2, svcC1, svcC2. What i want to happen is (where "restart" is beginning execution and "x" means finished)

time  > > > > > > > > > > > > >
svcA1 restart
- x
svcA2           restart
- - - x
--------------------------------
svcB1 restart x
svcB2         restart
x
--------------------------------
svcC1 restart
- - - - x
svcC2                 restart x

So all the services labeled 1 start at the same time, and then all subsequent services happen as soon as the previous in the group complete. It feels like I'd ideally want something like the COMPLETELY made up:

- name: restart all things
  group_by
: server_name
  inner_task
:
 
- name: restart server
    serial
: 1
    command
: ./restart.sh


I kind of have this (theoretically, untested) working with something like:

- name: restart all the things
  command
: ./resart_all_the_things.sh
  run_once
: true
  delegate_to
: localhost


but... that feels hacky and missing the point?

Thanks!

Serge van Ginderachter

unread,
May 13, 2015, 8:17:36 AM5/13/15
to ansible...@googlegroups.com

There is no way to do such a thing properly, I'm afraid, but I have been wanting this feature myself.

My use case is similar: I have lots of clusters, that are managed by the same setup type (the same roles), but deploy a different application (different inventory vars), and I'd like to deploy different clusters in parallel, but each node within the cluster serially.

Now, in the upcoming v2, there are new ways to handle the executions (strategy plugins), and I'd love to find out if that may present a way to implement such a thing.
Of course this would need a way to tell ansible which groups holds all the clusters, and which groups hold the nodes of a particular cluster, so AFAICS, we wil need more information from the inventory than we now can have..


   Serge


--
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/6edf2893-4e83-4539-8d96-c3ca9877f84e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages