From 6f2cf821472ef7b11fe5ce308cbf6cf89a332d5f Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Thu, 20 Nov 2014 08:09:15 -0500 Subject: [PATCH] Setup supervisor to manage uwsgi + mailsink servers. Use service command directly in controlling NGINX. --- config/supervisor/supervisor.conf | 0 deployment.yaml | 3 ++- deployment/email_server.yaml | 1 - deployment/supervisord.yaml | 15 +++++++++++++++ deployment/uwsgi.yaml | 7 ++++++- pre_deployment/nginx.yaml | 2 +- 6 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 config/supervisor/supervisor.conf create mode 100644 deployment/supervisord.yaml diff --git a/config/supervisor/supervisor.conf b/config/supervisor/supervisor.conf new file mode 100644 index 0000000..e69de29 diff --git a/deployment.yaml b/deployment.yaml index 2b05c12..e605f7a 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -1,4 +1,5 @@ --- - include: deployment/rookeries_install.yaml -- include: deployment/email_server.yaml - include: deployment/uwsgi.yaml +- include: deployment/email_server.yaml +- include: deployment/supervisor.yaml diff --git a/deployment/email_server.yaml b/deployment/email_server.yaml index 68cbf36..df4b30b 100644 --- a/deployment/email_server.yaml +++ b/deployment/email_server.yaml @@ -1,6 +1,5 @@ --- - hosts: all - sudo: yes vars: web_server_home: /srv/www email_server_venv: "{{ web_server_home }}/mail_server" diff --git a/deployment/supervisord.yaml b/deployment/supervisord.yaml new file mode 100644 index 0000000..a8bd8f0 --- /dev/null +++ b/deployment/supervisord.yaml @@ -0,0 +1,15 @@ +--- +- hosts: all + vars: + web_server_home: /srv/www + supervisor_venv: "{{ web_server_home }}/supervisord" + tasks: + + - name: PIP install supervisor into target virtualenv + pip: name=supervisor virtualenv={{ supervisor }} version=4.0.0-dev extra_args=--pre + + - name: Upload rookeries supervisor configuration to web server home + copy: src=../config/supervisor/supervisor.conf dest={{ web_server_home }} + + # TODO Clean up configuration placement + # TODO Control supervisor with supervisorctl + ansible - http://docs.ansible.com/supervisorctl_module.html diff --git a/deployment/uwsgi.yaml b/deployment/uwsgi.yaml index df5d1b8..6b12034 100644 --- a/deployment/uwsgi.yaml +++ b/deployment/uwsgi.yaml @@ -6,11 +6,16 @@ rookeries_uwsgi_ini: rookeries-uwsgi.ini tasks: - - name: PIP install mailsink test server into target virtualenv + - name: PIP install UWSGI server into target virtualenv pip: name=uwsgi virtualenv={{ uwsgi_venv }} version=2.0 + - name: PIP install supervisord into target virtualenv + pip: name=supervisor virtualenv={{ uwsgi_venv }} version=4.0.0-dev extra_args=--pre + - name: Upload rookeries UWSGI configuration to web server home copy: src=../config/uwsgi/{{ rookeries_uwsgi_ini }} dest={{ web_server_home }} + # TODO Clean up configuration placement + # - name: Launches the UWSGI daemon # command: "{{ uwsgi_venv }}/bin/uwsgi --ini {{ web_server_home }}/{{ rookeries_uwsgi_ini }}" diff --git a/pre_deployment/nginx.yaml b/pre_deployment/nginx.yaml index e4c478e..dd37ef7 100644 --- a/pre_deployment/nginx.yaml +++ b/pre_deployment/nginx.yaml @@ -22,7 +22,7 @@ file: state=absent path=/etc/nginx/sites-enabled/default - name: Run nginx service - command: service nginx restart + service: name=nginx state=restarted - name: Setup webapp deployment folder with the correct permissions file: path={{ web_server_home }} state=directory