--- - hosts: all sudo: yes 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 }} - 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 - 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