I've got a server on which Supervisord is managing my processes. I normally start supervisord with the following command:
sudo /var/www/imd/venv/bin/supervisord -c /var/www/imd/deploy/supervisord.conf
I'm now trying to set things up with Ansible, but I'm unsure of how I should start Ansible. I can of course do it using something like:
- name: run supervisord
command: "/var/www/imd/venv/bin/supervisord -c /var/www/imd/deploy/supervisord.conf"
This works, but only the first time that you run it. Second time you run the same script supervisord is of course already running, which causes the following error:
TASK [run supervisord] ******************************************************* fatal: [ansible-test1]: FAILED! => {"changed": true, "cmd": ["/var/www/imd/venv/bin/supervisord", "-c", "/var/www/imd/deploy/supervisord.conf"], "delta": "0:00:00.111700", "end": "2016-06-03 11:57:38.605804", "failed": true, "rc": 2, "start": "2016-06-03 11:57:38.494104", "stderr": "Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.\nFor help, use /var/www/imd/venv/bin/supervisord -h", "stdout": "", "stdout_lines": [], "warnings": []}
Does anybody know how I can correctly run supervisord with Ansible? All tips are welcome!
[EDIT]
Because the solution in the answer by mbarthelemy doesn't work for socket files I now managed to get it working with the following:
- name: run supervisord
shell: if [ ! -S /var/run/supervisor.sock ]; then sudo /var/www/imd/venv/bin/supervisord -c /var/www/imd/deploy/supervisord.conf; fi
This of course is not very "ansibleish". If anybody has a real Ansible-based solution that would still be really welcome.