---

- name: Install Supervisor using pip
  pip:
    name: supervisor
    state: present
    extra_args: "{{ pip_extra_args | default('') }}"

- name: Ensure that Supervisor directories are created
  file:
    path: "{{ item }}"
    state: directory
    owner: root
    group: root
    mode: 0755
  with_items:
    - /etc/supervisor
    - /etc/supervisor/conf.d
    - /var/log/supervisor

- name: Copy default configuration file
  copy:
    src: supervisord.conf
    dest: /etc/supervisord.conf
    force: no # no don't destroy the file if exist
              # even if content is different
  notify: Restart Supervisor

- name: Generate init script (Debian)
  copy:
    src: supervisord-init.d
    dest: /etc/init.d/supervisord
    owner: root
    group: root
    mode: 0755
  # TODO: Replace init.d var
  when: ansible_os_family == "Debian"

- name: Ensure Supervisor is running and start at boot
  systemd:
    name: supervisord
    state: started
    enabled: yes
    daemon_reload: yes

# vim: sw=2

---

- name: Install Supervisor using pip
  pip:
    name: supervisor
    state: present
    extra_args: "{{ pip_extra_args | default('') }}"

- name: Ensure that Supervisor directories are created
  file:
    path: "{{ item }}"
    state: directory
    owner: root
    group: root
    mode: 0755
  with_items:
    - /etc/supervisor
    - /etc/supervisor/conf.d
    - /var/log/supervisor

- name: Copy default configuration file
  copy:
    src: supervisord.conf
    dest: /etc/supervisord.conf
    force: no # no don't destroy the file if exist
              # even if content is different
  notify: Restart Supervisor

- name: Generate init script (Debian)
  copy:
    src: supervisord-init.d
    dest: /etc/init.d/supervisord
    owner: root
    group: root
    mode: 0755
  # TODO: Replace init.d var
  when: ansible_os_family == "Debian"

- name: Ensure Supervisor is running and start at boot
  systemd:
    name: supervisord
    state: started
    enabled: yes
    daemon_reload: yes

# https://github.com/ansible/ansible-modules-core/issues/3764
- name: Temporary workaround to enable supervisord at boot
  command: systemctl enable supervisord.service
# vim: sw=2

Add temporary workaround to enable supervisord at boot
Add temporary workaround to enable supervisord at boot
