2014-11-20 18:05:34 -05:00
|
|
|
---
|
|
|
|
- hosts: all
|
2014-11-21 23:09:42 -05:00
|
|
|
sudo: yes
|
2014-11-20 18:05:34 -05:00
|
|
|
vars:
|
|
|
|
web_server_home: /srv/www
|
|
|
|
web_server_group: www-data
|
|
|
|
supervisor_config: "{{ web_server_home }}/config/supervisor"
|
|
|
|
supervisor_venv: "{{ web_server_home }}/supervisor"
|
|
|
|
tasks:
|
|
|
|
|
|
|
|
- name: PIP install supervisor into target virtualenv
|
|
|
|
pip: name=supervisor virtualenv={{ supervisor_venv }} version=3.1.3 extra_args=--pre
|
|
|
|
|
|
|
|
- name: Setup webapp deployment configuration folder with the correct permissions
|
|
|
|
file: path={{ supervisor_config }} state=directory
|
|
|
|
owner={{ ansible_env.SUDO_USER }} group={{ web_server_group }} mode=0774
|
|
|
|
|
|
|
|
- name: Upload rookeries supervisor configuration to web server home
|
|
|
|
copy: src=../config/supervisor/supervisor.conf dest={{ supervisor_config }}
|
|
|
|
|
2014-11-21 23:09:42 -05:00
|
|
|
- name: Link supervisor binary into /usr/local/bin
|
|
|
|
file: src={{ supervisor_venv }}/bin/{{ item }} dest=/usr/local/bin/{{ item }} state=link
|
|
|
|
with_items:
|
|
|
|
- supervisord
|
|
|
|
- supervisorctl
|
|
|
|
|
2014-11-24 08:07:24 -05:00
|
|
|
# TODO Separate out starting and stopping of supervisord + supervisorctl outside of provisioning
|
2014-11-21 23:09:42 -05:00
|
|
|
- name: Check if supervisord is running
|
|
|
|
shell: pgrep supervisor
|
|
|
|
ignore_errors: on
|
|
|
|
changed_when: off
|
|
|
|
register: supervisor_running
|
|
|
|
|
|
|
|
- name: Running supervisord
|
|
|
|
shell: "{{ supervisor_venv }}/bin/supervisord -c {{ supervisor_config }}/supervisor.conf"
|
|
|
|
when: supervisor_running|failed
|
|
|
|
|
|
|
|
- name: Start up the mailsink program
|
|
|
|
supervisorctl: name=mailsink state=restarted config={{ supervisor_config }}/supervisor.conf
|
|
|
|
|
|
|
|
- name: Start up the uwsgi program
|
|
|
|
supervisorctl: name=uwsgi state=restarted config={{ supervisor_config }}/supervisor.conf
|