Hello,
I have 2 Ansible groups:
- nginx_servers.
- api_servers.
I am trying to automate following:
- Select 1 API server.
- Mark selected API server as down in the all nginx configs. Reload nginx.
- Restart selected API server.
- Mark selected API server as up in the all nginx configs.
- Goto 1. until all API servers are restarted.
Should I use Ansible for this? Any suggestions? hints? code samples?
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.
This documentation page should be helpful: http://docs.ansible.com/playbooks_conditionals.html#applying-when-to-roles-and-includes
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