add supervisor role

This commit is contained in:
Ryan Cavicchioni 2022-08-30 07:51:10 -05:00
parent 3a14992832
commit 49be68b4db
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
6 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,24 @@
---
supervisor_package_name: supervisor
supervisor_package_state: present
supervisor_service_name: supervisor
supervisor_service_state: started
supervisor_service_enabled: true
supervisor_etc_path: /etc/supervisor
supervisor_config_path: "{{ supervisor_etc_path }}/supervisord.conf"
supervisor_config_owner: root
supervisor_config_group: root
supervisor_config_mode: "0644"
supervisor_unix_http_server_socket_file: /var/run/supervisor.sock
supervisor_unix_http_server_socket_chmod: "0700"
supervisor_supervisord_logfile: /var/log/supervisor/supervisord.log
supervisor_supervisord_pidfile: /var/run/supervisord.pid
supervisor_supervisord_childlogdir: /var/log/supervisor
supervisor_supervisorctl_serverurl: "unix://{{ supervisor_unix_http_server_socket_file }}"
supervisor_include_files: /etc/supervisor/conf.d/*.conf

View File

@ -0,0 +1,5 @@
---
- name: restart supervisor
service:
name: "{{ supervisor_service_name }}"
state: restarted

View File

View File

@ -0,0 +1,44 @@
---
- name: gather os specific variables
include_vars: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- vars
- name: include os specific tasks
include_tasks: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- tasks
- name: install package
package:
name: "{{ supervisor_package_name }}"
state: "{{ supervisor_package_state }}"
- name: configure
template:
src: supervisord.conf.j2
dest: "{{ supervisor_config_path }}"
owner: "{{ supervisor_config_owner }}"
group: "{{ supervisor_config_group }}"
mode: "{{ supervisor_config_mode }}"
notify: restart supervisor
- name: manage service
service:
name: "{{ supervisor_service_name }}"
state: "{{ supervisor_service_state }}"
enabled: "{{ supervisor_service_enabled }}"

View File

@ -0,0 +1,26 @@
; {{ ansible_managed }}
[unix_http_server]
{% if supervisor_unix_http_server_socket_file is defined %}
file={{ supervisor_unix_http_server_socket_file }}
{% endif %}
{% if supervisor_unix_http_server_socket_chmod is defined %}
chmod={{ supervisor_unix_http_server_socket_chmod }}
{% endif %}
{% if supervisor_unix_http_server_socket_chown is defined %}
chown={{ supervisor_unix_http_server_socket_chown }}
{% endif %}
[supervisord]
logfile={{ supervisor_supervisord_logfile }}
pidfile={{ supervisor_supervisord_pidfile }}
childlogdir={{ supervisor_supervisord_childlogdir }}
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl={{ supervisor_supervisorctl_serverurl }}
[include]
files = {{ supervisor_include_files }}

View File