Skip to content

Commit

Permalink
Allow using APT to install Supervisor
Browse files Browse the repository at this point in the history
Two main reasons to prefer using apt:

* On Debian 12, installing supervisor with pip as a global package, like
  this role does, is no longer permitted.
* Pip needs compilers and other dangerous packages, that should not be
  installed if not needed.

A variable is introduced to allow for this, by default the role behaves
as it did before, i.e. uses pip.
  • Loading branch information
Yassine Zouggari committed Sep 8, 2023
1 parent b460996 commit cf2ec12
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ An Ansible Role that installs [Supervisor](http://supervisord.org/) on Linux.

## Requirements

Python `pip` should be installed. If it is not already installed, you can use the `geerlingguy.pip` Ansible role to install Pip prior to running this role.
### Using `pip`

By default, Python `pip` is used to install Supervisor, it hence should be installed. If it is not already installed, you can use the `geerlingguy.pip` Ansible role to install Pip prior to running this role.

### Using `apt`

On distributions that support it and if Supervisor is packaged, you can use `apt` to install Supervisor by specifying, as a variable:

supervisor_apt_install: true

Depending on your distribution, the binary paths (default: `/usr/bin/local/supervisor` and `/usr/bin/local/supervisorctl`) can be overwritten:

supervisor_bin_path: /usr/bin/supervisor
supervisorctl_bin_path: /usr/bin/supervisorctl

## Role Variables

Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ supervisor_version: ''
supervisor_started: true
supervisor_enabled: true

supervisor_apt_install: false

supervisor_config_path: /etc/supervisor

# A list of `program`s Supervisor will control. Example commented out below.
Expand Down
7 changes: 7 additions & 0 deletions tasks/init-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@
mode: 0644
when: "ansible_service_mgr == 'systemd'"
notify: restart supervisor

- name: Disable default supervisor systemd service when installing with APT.
systemd:
name: supervisor
state: stopped
enabled: false
when: supervisor_apt_install
9 changes: 8 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_os_family }}.yml"

- name: Ensure Supervisor is installed.
- name: Ensure Supervisor is installed using pip.
pip:
name: supervisor
state: present
version: "{{ supervisor_version | default(omit) }}"
when: not supervisor_apt_install

- name: Ensure Supervisor is installed using apt.
pip:
name: "supervisor={{ supervisor_version | default('*') }}"
state: present
when: supervisor_apt_install

- name: Ensure Supervisor log dir exists.
file:
Expand Down

0 comments on commit cf2ec12

Please sign in to comment.