---

- name: Create the Supervisor config file
  template: src=supervisor_config.j2
            dest=/etc/supervisor/conf.d/{{ application_name }}.conf
            backup=yes

- name: Re-read the Supervisor config files
  supervisorctl: name={{ application_name }} state=present

- name: Restart Supervisor
  supervisorctl: name={{ application_name }}
                 state=restarted
  changed_when: False

---


- name: Make sure Supervisor is installed
  apt: name=supervisor update_cache={{ update_apt_cache }} state=installed

- name: Ensure supervisor service is started
  service: name=supervisor state=started enabled=yes

- name: Create the Supervisor config file
  template: src=supervisor_config.j2
            dest=/etc/supervisor/conf.d/{{ application_name }}.conf
            backup=yes

- name: Re-read the Supervisor config files
  supervisorctl: name={{ application_name }} state=present

- name: Restart Supervisor
  supervisorctl: name={{ application_name }}
                 state=restarted
  changed_when: False

Make sure Supervisor is installed and enabled before running tasks.
Make sure Supervisor is installed and enabled before running tasks.
