Run command on 1 server from group A, then run another command on 1 from group B, in loop

34 views
Skip to first unread message

Vladimir Mihailenco

unread,
Apr 10, 2014, 10:32:36 AM4/10/14
to ansible...@googlegroups.com
Hello,

I have 2 Ansible groups:
- nginx_servers.
- api_servers.

I am trying to automate following:
1. Select 1 API server.
2. Mark selected API server as down in the all nginx configs. Reload nginx.
3. Restart selected API server.
4. Mark selected API server as up in the all nginx configs.
5. Goto 1. until all API servers are restarted.

Should I use Ansible for this? Any suggestions? hints? code samples?

Paul Durivage

unread,
Apr 10, 2014, 12:22:04 PM4/10/14
to ansible...@googlegroups.com
I don't have any examples for you, but Ansible is definitely the right tool for this kind of orchestration.  I'm sure someone here can provide some samples.

You'll want to write a playbook that enumerates these steps.  Use the "serial" directive in your play so that only one server is touched at once before moving on to the next.



--
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/31974a08-c3af-48ae-887f-2a2e4f6fae73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Janssen

unread,
Apr 11, 2014, 9:17:39 AM4/11/14
to ansible...@googlegroups.com
This should be easy with ansible... make sure you use 'serial 1' ... so you only work on one host at a time.
Then use 'delegate_to' tasks to remove/add the hosts to your nginx config/reload configs

Mark


--
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/31974a08-c3af-48ae-887f-2a2e4f6fae73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mark Janssen  --  maniac(at)maniac.nl
Unix / Linux Open-Source and Internet Consultant
Maniac.nl Sig-IO.nl Vps.Stoned-IT.com

Reply all
Reply to author
Forward
0 new messages