buluma.supervisor
Ansible 角色 supervisor
Supervisor(进程状态管理器)用于 Linux。
GitHub | 版本 | 问题 | 拉取请求 | 下载 |
---|---|---|---|---|
示例剧本
此示例来自 molecule/default/converge.yml
,并在每次推送、拉取请求和发布时进行测试。
---
- name: 收敛
hosts: all
become: true
environment:
PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
vars:
supervisor_user: root
supervisor_password: fizzbuzz
pre_tasks:
- name: 更新 apt 缓存 (Debian)。
apt: update_cache=true cache_valid_time=600
when: ansible_os_family == 'Debian'
# 安装 curl 进行测试。
- name: 安装 curl 以便测试。
package: name=curl state=present
# 安装 Apache 进行测试。
- block:
- name: 安装 Apache (RedHat)。
package: name=httpd state=present
- name: 确保 Apache 不在运行 (RedHat)。
service: name=httpd state=stopped enabled=no
when: ansible_os_family == 'RedHat'
- block:
- name: 安装 Apache (Debian)。
package: name=apache2 state=present
- name: 确保 Apache 不在运行 (Debian)。
service: name=apache2 state=stopped enabled=no
when: ansible_os_family == 'Debian'
- name: 创建一个测试 HTML 文件进行加载。
ansible.builtin.copy:
content: "<html><head><title>测试</title></head><body>测试。</body></html>"
dest: /var/www/html/index.html
force: false
group: root
owner: root
mode: 0644
# 将 Apache 添加到 supervisor_programs。
- name: 设置 Apache 启动命令 (Debian)。
ansible.builtin.set_fact:
apache_start_command: apache2ctl -DFOREGROUND
when: ansible_os_family == 'Debian'
- name: 设置 Apache 启动命令 (RedHat)。
ansible.builtin.set_fact:
apache_start_command: httpd -DFOREGROUND
when: ansible_os_family == 'RedHat'
- name: 将 Apache 添加到 supervisor_programs。
ansible.builtin.set_fact:
supervisor_programs:
- name: 'apache'
command: "{{ apache_start_command }}"
state: present
configuration: |
autostart=true
autorestart=true
startretries=1
startsecs=1
redirect_stderr=true
stderr_logfile=/var/log/apache-err.log
stdout_logfile=/var/log/apache-out.log
user=root
killasgroup=true
stopasgroup=true
roles:
- role: buluma.supervisor
tasks:
- name: 触发处理程序,以便 supervisor 运行所有应运行的内容。
ansible.builtin.meta: flush_handlers
post_tasks:
- name: 等待 Apache 启动(如果它会启动的话)。
ansible.builtin.wait_for:
port: 80
delay: 2
- name: 验证 Apache 是否在 80 端口响应。
ansible.builtin.uri:
url: http://127.0.0.1/
method: GET
status_code: 200
- name: 验证 supervisorctl 是否可用。
command: supervisorctl --help
args:
warn: false
changed_when: false
- name: 验证 supervisorctl 是否通过默认的 UNIX 套接字工作。
community.general.supervisorctl:
name: apache
state: restarted
username: "{{ supervisor_user }}"
password: "{{ supervisor_password }}"
changed_when: false
- name: 验证 supervisorctl 是否与 UNIX 套接字一起工作。
command: supervisorctl status
args:
warn: false
changed_when: false
需要准备机器。在 CI 中,这通过 molecule/default/prepare.yml
完成:
---
- name: 准备
hosts: all
gather_facts: no
become: yes
serial: 30%
roles:
- role: buluma.bootstrap
- role: buluma.pip
- role: buluma.core_dependencies
另请查看 完整说明和示例 如何使用这些角色。
角色变量
变量的默认值在 defaults/main.yml
中设置:
---
# 通过在这里设置特定版本来安装 Supervisor(例如 '3.3.1')。
supervisor_version: ''
# 选择在安装 Supervisor 时和/或系统启动后使用 init 脚本或 systemd 单元配置来启动 Supervisor。
supervisor_started: true
supervisor_enabled: true
supervisor_config_path: /etc/supervisor
# Supervisor 将控制的 `program` 列表。以下示例已注释。
supervisor_programs: []
# - name: 'apache'
# command: apache2ctl -c "ErrorLog /dev/stdout" -DFOREGROUND
# state: present
# configuration: |
# autostart=true
# autorestart=true
# startretries=1
# startsecs=1
# redirect_stderr=true
# stderr_logfile=/var/log/apache-err.log
# stdout_logfile=/var/log/apache-out.log
# user=root
# killasgroup=true
# stopasgroup=true
supervisor_nodaemon: false
supervisor_log_dir: /var/log/supervisor
supervisor_user: root
supervisor_password: 'my_secret_password'
supervisor_unix_http_server_enable: true
supervisor_unix_http_server_socket_path: /var/run/supervisor.sock
supervisor_unix_http_server_password_protect: true
supervisor_inet_http_server_enable: false
supervisor_inet_http_server_port: '*:9001'
supervisor_inet_http_server_password_protect: true
要求
- requirements.txt 中列出的 pip 包。
已使用角色的状态
以下角色用于准备系统。您可以以不同的方式准备您的系统。
需求 | GitHub | 版本 |
---|---|---|
buluma.bootstrap | ||
buluma.pip | ||
buluma.core_dependencies |
上下文
该角色是多个兼容角色的一部分。有关更多信息,请查看 这些角色的文档。
以下是相关角色的概述:
兼容性
该角色已在以下 容器镜像 上进行测试:
容器 | 标签 |
---|---|
EL | 8 |
Debian | 所有 |
Ubuntu | 所有 |
Kali | 所有 |
所需的最低 Ansible 版本为 2.12,已进行测试包括:
- 之前的版本。
- 当前版本。
- 开发版本。
如果您发现问题,请在 GitHub 上登记。
更新日志
许可证
作者信息
关于项目
Supervisor (process state manager) for Linux.
安装
ansible-galaxy install buluma.supervisor
许可证
apache-2.0
下载
4k
拥有者
DevOps Engineer