Skip to content

Instantly share code, notes, and snippets.

@artschwagerb
Created January 11, 2016 20:15
Show Gist options
  • Save artschwagerb/64a713d3c4e8caaa3bf8 to your computer and use it in GitHub Desktop.
Save artschwagerb/64a713d3c4e8caaa3bf8 to your computer and use it in GitHub Desktop.
Deploy Django App using Ansible
---
- hosts: django_app_servers
serial: 1
remote_user: admin
sudo: yes
tasks:
- name: Send Maintenance Mode Command to HaProxy
shell: curl --data "s={{inventory_hostname}}&b=#12&action=drain" http://user:[email protected]:8080/haproxy?stats
- name: Waiting for Clients to Drain
pause: prompt="Waiting for Clients to Drain" seconds=15
- name: Stop Supervisor Django App
supervisorctl: name=django state=stopped
- name: Stop Supervisor Celery App
supervisorctl: name=celery state=stopped
- name: Pull New Code From GitHub
shell: python /var/apps/django/scripts/git_pull.py
become: yes
become_user: django
- name: Start Supervisor Django App
supervisorctl: name=django state=started
- name: Start Supervisor Celery App
supervisorctl: name=celery state=started
- name: Waiting for Services to Stabilize
pause: prompt="Waiting 15 Seconds for Services to Stabilize" seconds=15
- name: Send Ready Command to HaProxy
shell: curl --data "s={{inventory_hostname}}&b=#12&action=ready" http://user:[email protected]:8080/haproxy?stats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment