Rolling deploys to groups of servers

Hello!

I have the requirement to perform rolling deploys to groups of servers at a time, e.g. the first set of servers - app1_server_1, app2_server_1, app3_server1 - first, then the second set - app1_server2, app2_server2, app3_server2 - then the third set, app1_server3, app2_server3, app3_server3, etc.

Anyone know of a good way to do this in ansible?

Thanks a lot,

Guy

several, one way is:

- hosts: app*_server1:app*_server2:app*_server3
  serial: 3

Hi Guy,
First you need a way to refer to your servers in the required release order. Easy way is to just have them as a group in your host file such as:

[servers]
server1
server2
server3

serverN

Then in your rolling deploy playbook, you refer to this group as hosts, and use serial=1 if you would like Ansible to finish all apps in one server before moving on to the next one.

To force the app order, you can create task lists for each deploy, and then include them in order, such as:

hosts: servers
serial:1
.
.
.
tasks:

  • include : deploy_app1
  • include: deploy_app2
  • include: deploy_app3

Hope it helps !

Great! That looks like it’ll work! What’s another way? :wink:

Thanks,

Guy