From 00f779639c45c470becc90db74cf172e58241cf4 Mon Sep 17 00:00:00 2001 From: Logan V Date: Wed, 9 Nov 2016 22:47:36 -0600 Subject: [PATCH] Use ansible_service_mgr fact This patch removes some extra tasks for detecting systemd and uses the fact instead. Partial-Bug: #1640125 Change-Id: Ie23bdd2fe44d22ff19699f5c9bef9a71d190be45 --- tasks/main.yml | 14 -------------- tasks/nova_disable_smt.yml | 4 ++-- tasks/nova_init_common.yml | 6 ++++-- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index e9a264c4..12133bb5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,20 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Detect whether the init system is upstart of systemd. -- name: Check init system - command: cat /proc/1/comm - changed_when: false - register: _pid1_name - tags: - - always - -- name: Set the name of pid1 - set_fact: - pid1_name: "{{ _pid1_name.stdout }}" - tags: - - always - - name: Gather variables for each operating system include_vars: "{{ item }}" with_first_found: diff --git a/tasks/nova_disable_smt.yml b/tasks/nova_disable_smt.yml index 95963e95..d5cfd758 100644 --- a/tasks/nova_disable_smt.yml +++ b/tasks/nova_disable_smt.yml @@ -28,7 +28,7 @@ owner: "root" group: "root" when: - - pid1_name == "systemd" + - ansible_service_mgr == 'systemd' notify: - Reload systemd daemon @@ -37,6 +37,6 @@ src: "smt.conf" dest: "/etc/init/smt.conf" when: - - pid1_name != "systemd" + - ansible_service_mgr != 'systemd' notify: - Reload upstart init scripts diff --git a/tasks/nova_init_common.yml b/tasks/nova_init_common.yml index 0a033095..82384cd5 100644 --- a/tasks/nova_init_common.yml +++ b/tasks/nova_init_common.yml @@ -14,10 +14,12 @@ # limitations under the License. - include: nova_init_upstart.yml - when: pid1_name == "init" + when: + - ansible_service_mgr == 'upstart' - include: nova_init_systemd.yml - when: pid1_name == "systemd" + when: + - ansible_service_mgr == 'systemd' - name: Load service service: