diff --git a/roles/supervisor/defaults/main.yaml b/roles/supervisor/defaults/main.yaml new file mode 100644 index 0000000..02cea5f --- /dev/null +++ b/roles/supervisor/defaults/main.yaml @@ -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 diff --git a/roles/supervisor/handlers/main.yaml b/roles/supervisor/handlers/main.yaml new file mode 100644 index 0000000..b1933a7 --- /dev/null +++ b/roles/supervisor/handlers/main.yaml @@ -0,0 +1,5 @@ +--- +- name: restart supervisor + service: + name: "{{ supervisor_service_name }}" + state: restarted diff --git a/roles/supervisor/tasks/default.yaml b/roles/supervisor/tasks/default.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/supervisor/tasks/main.yaml b/roles/supervisor/tasks/main.yaml new file mode 100644 index 0000000..8f05dc6 --- /dev/null +++ b/roles/supervisor/tasks/main.yaml @@ -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 }}" diff --git a/roles/supervisor/templates/supervisord.conf.j2 b/roles/supervisor/templates/supervisord.conf.j2 new file mode 100644 index 0000000..d33c09d --- /dev/null +++ b/roles/supervisor/templates/supervisord.conf.j2 @@ -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 }} diff --git a/roles/supervisor/vars/default.yaml b/roles/supervisor/vars/default.yaml new file mode 100644 index 0000000..e69de29