From f44839f933789d8b90608134886e3aa4f8f62659 Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Wed, 17 Aug 2016 16:46:56 +0900 Subject: [PATCH] systemd vs upstart, detect it smart --- tasks/supervisor.yml | 21 ++++++++++++------- ...ian.conf.j2 => supervisor_systemd.conf.j2} | 0 ...sor.conf.j2 => supervisor_upstart.conf.j2} | 0 3 files changed, 13 insertions(+), 8 deletions(-) rename templates/{supervisor_debian.conf.j2 => supervisor_systemd.conf.j2} (100%) rename templates/{supervisor.conf.j2 => supervisor_upstart.conf.j2} (100%) diff --git a/tasks/supervisor.yml b/tasks/supervisor.yml index f33d296..bb9b847 100644 --- a/tasks/supervisor.yml +++ b/tasks/supervisor.yml @@ -25,17 +25,22 @@ notify: - supervisor restart -- name: Configure supervisor (Ubuntu) - pt. 2 - template: src=supervisor.conf.j2 dest=/etc/init/supervisor.conf owner=root group=root mode=0755 - when: ansible_distribution == 'Ubuntu' +- name: Find systemd information + command: which systemctl + ignore_errors: yes + register: is_systemd -- name: Configure supervisor (Debian) - pt. 2 - template: src=supervisor_debian.conf.j2 dest=/etc/init.d/supervisor owner=root group=root mode=0755 - when: ansible_distribution == 'Debian' +- name: Configure upstart supervisor + template: src=supervisor_upstart.conf.j2 dest=/etc/init/supervisor.conf owner=root group=root mode=0755 + when: not is_systemd -- name: Enable supervisor service (Debian) - pt. 3 +- name: Configure systemd supervisor + template: src=supervisor_systemd.conf.j2 dest=/etc/init.d/supervisor owner=root group=root mode=0755 + when: is_systemd + +- name: Enable systemd supervisor service service: name=supervisor enabled=yes - when: ansible_distribution == 'Debian' + when: is_systemd - name: Ensure the supervisor is started service: name=supervisor state=started diff --git a/templates/supervisor_debian.conf.j2 b/templates/supervisor_systemd.conf.j2 similarity index 100% rename from templates/supervisor_debian.conf.j2 rename to templates/supervisor_systemd.conf.j2 diff --git a/templates/supervisor.conf.j2 b/templates/supervisor_upstart.conf.j2 similarity index 100% rename from templates/supervisor.conf.j2 rename to templates/supervisor_upstart.conf.j2