问题原文
原帖链接 · Luke · CC BY-SA 3.0
I'm trying to restart Supervisor through my Ansible Playbook but I seem to be stumbling into an issue with the supervisor module for Ansible.
In my Supervisor config I have defined a program:
[program:process]
process_name=%(program_name)s_%(process_num)02d
command=/home/box1/workers/bin/process
numprocs=64
directory=/home/box1/workers/bin
autostart=true
autorestart=true
startretries=5
stderr_logfile=/tmp/%(program_name)s-err.log
stdout_logfile=/tmp/%(program_name)s-out.log
user=root
And this works fine. However, when I try to restart Supervisor through Ansible I get the following error:
failed: [box1] => {"failed": true}
msg: program:process: ERROR (no such process)
program:process: ERROR (no such process)
My Ansible task configuration looks like this:
- name: Restart Supervisor
sudo: yes
supervisorctl: name=program:process state=restarted config=/etc/supervisor/supervisord.conf
For the name parameter I have tried program:process, program, program: and process but none seem to work. I'm currently on Ansible 1.5.4.
社区高分解答
原帖链接 · 300D7309EF17 · CC BY-SA 3.0
The supervisorctl Ansible module does not support the reload command (see here), which is needed for supervisor to pick up new configuration entries.
You can do it yourself like this:
- command: supervisorctl reread
sudo: yes
- supervisorctl: name=program:process state=restarted config=/etc/supervisor/supervisord.conf
sudo: yes
The documentation on reload/reread/update/restart seems to be missing, and this blog post is out of date; you can experiment to make sure reload does what you expect.
Finally, don't put your program definitions in supervisord.conf. Instead, put them as individual files in /etc/supervisor/conf.d/*.conf. That makes installation and maintenance much easier.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
