Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ansible Playbook for seamless deployment with Docker.
---
- hosts: app_server_1
user: ubuntu
sudo: true
roles:
- docker_rails_app_build
- hosts: app_loadbalancer
user: ubuntu
sudo: true
tasks:
- name: take app_1 out of balancing
replace: dest=/etc/nginx/conf.d/default.conf regexp="server {{app_server_1}}\:8080\;" replace='# server {{app_server_1}}:8080;' backup=false
- name: restart nginx
shell: service nginx restart
- hosts: app_server_1
user: ubuntu
sudo: true
roles:
- docker_rails_app_run_prod
- docker_rails_app_push
- hosts: app_loadbalancer
user: ubuntu
sudo: true
tasks:
- name: take app_1 back to balancing
replace: dest=/etc/nginx/conf.d/default.conf regexp="\# server {{app_server_1}}\:8080\;" replace='server {{app_server_1}}:8080;' backup=false
- name: take app_2 out of balancing
replace: dest=/etc/nginx/conf.d/default.conf regexp="server {{app_server_2}}\:8080\;" replace='# server {{app_server_2}}:8080;' backup=false
- name: restart nginx
shell: service nginx restart
- hosts: app_server_2
user: ubuntu
sudo: true
roles:
- docker_rails_app_run_prod
- hosts: app_loadbalancer
user: ubuntu
sudo: true
tasks:
- name: wait a minute until Docker container is up and running
pause: minutes=1
- name: take app_2 back to balancing
replace: dest=/etc/nginx/conf.d/default.conf regexp="\# server {{app_server_2}}\:8080\;" replace='server {{app_server_2}}:8080;' backup=false
- name: take app_3 out of balancing
replace: dest=/etc/nginx/conf.d/default.conf regexp="server {{app_server_3}}\:8080\;" replace='# server {{app_server_3}}:8080;' backup=false
- name: restart nginx
shell: service nginx restart
- hosts: app_server_3
user: ubuntu
sudo: true
roles:
- docker_rails_app_run_prod
- hosts: app_loadbalancer
user: ubuntu
sudo: true
tasks:
- name: wait a minute until Docker container is up and running
pause: minutes=1
- name: take app_3 back to balancing
replace: dest=/etc/nginx/conf.d/default.conf regexp="\# server {{app_server_3}}\:8080\;" replace='server {{app_server_3}}:8080;' backup=false
- name: restart nginx
shell: service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment