Ansible 部署 Supervisor
[deploy]
aliyun_ecs ansible_ssh_host=47.96.25.224 ansible_ssh_port=22 ansible_user=ecs-user ansible_ssh_pass=Ecs-user123 ansible_sudo_pass=Ecs-user123Last updated
[deploy]
aliyun_ecs ansible_ssh_host=47.96.25.224 ansible_ssh_port=22 ansible_user=ecs-user ansible_ssh_pass=Ecs-user123 ansible_sudo_pass=Ecs-user123Last updated
[inet_http_server]
port = :9001
username = admin
password = 123456
[include]
files =/etc/supervisord.d/conf.d/*.ini
[supervisord]
logfile = /var/log/supervisor/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
pidfile = /var/run/supervisord.pid
nodaemon = false
minfds = 65535
#minprocs = 200
umask = 022
user = root
identifier = supervisor
nocleanup = true
childlogdir = /tmp
strip_ansi = false
[supervisorctl]
serverurl = http://127.0.0.1:9001
username = admin
password = 123456
prompt = supervisor
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface[Unit]
Description=Supervisor daemon
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.d/supervisor.conf
ExecStop=/usr/bin/supervisorctl -c /etc/supervisord.d/supervisor.conf shutdown
ExecReload=/usr/bin/supervisorctl -c /etc/supervisord.d/supervisor.conf reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target---
- name: 安装 Supervisor
hosts: deploy
become: true
tasks:
- name: 安装 Supervisor 包
apt:
name: supervisor
state: present
when: ansible_os_family == 'Debian'
- name: 安装 Supervisor 包
yum:
name: supervisor
state: present
when: ansible_os_family == 'RedHat'
- name: 配置 Supervisor 配置文件
copy:
src: supervisor.conf
dest: /etc/supervisord.d/supervisor.conf
owner: root
- name: 配置 supervisord systemctl 服务
copy:
src: supervisord.service
dest: /usr/lib/systemd/system/supervisord.service
owner: root
- name: 启用并启动 Supervisor 服务
service:
name: supervisord
state: restarted
enabled: true
daemon_reload: true
- name: 检查端口是否运行
wait_for: port=9001 state=started delay=1 timeout=30
$ ansible-playbook deploy-supervisor.yml -i deploy-supervisor-host.ini
PLAY [安装 Supervisor] **************************************************************************************
TASK [Gathering Facts] **************************************************************************************
ok: [aliyun_ecs]
TASK [安装 Supervisor 包] ***********************************************************************************
skipping: [aliyun_ecs]
TASK [安装 Supervisor 包] ***********************************************************************************
ok: [aliyun_ecs]
TASK [配置 Supervisor 配置文件] *****************************************************************************
ok: [aliyun_ecs]
TASK [配置 supervisord systemctl 服务] **********************************************************************
ok: [aliyun_ecs]
TASK [启用并启动 Supervisor 服务] ***************************************************************************
changed: [aliyun_ecs]
TASK [检查端口是否运行] *************************************************************************************
ok: [aliyun_ecs]
PLAY RECAP **************************************************************************************************
aliyun_ecs : ok=5 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0