From 714b846aad2a6510949ebfeacd5ddaed6cb6844a Mon Sep 17 00:00:00 2001
From: Logan V <logan2211@gmail.com>
Date: Wed, 9 Nov 2016 22:24:03 -0600
Subject: [PATCH] Use ansible_service_mgr fact

This patch removes some extra tasks for detecting systemd and uses
the `ansible_service_mgr` fact instead.

Partial-Bug: #1640125
Change-Id: I1a30b79a759057afb74f24f2239f474b60c1db35
---
 handlers/main.yml             |  2 +-
 tasks/galera_post_install.yml |  6 +++---
 tasks/main.yml                | 13 -------------
 3 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/handlers/main.yml b/handlers/main.yml
index c2ba24be..90b867ad 100644
--- a/handlers/main.yml
+++ b/handlers/main.yml
@@ -16,7 +16,7 @@
 - name: Reload the systemd daemon
   command: "systemctl daemon-reload"
   when:
-    - pid1_name == "systemd"
+    - ansible_service_mgr == 'systemd'
 
 - name: Restart mysql
   service:
diff --git a/tasks/galera_post_install.yml b/tasks/galera_post_install.yml
index 26690ec5..cbc93db3 100644
--- a/tasks/galera_post_install.yml
+++ b/tasks/galera_post_install.yml
@@ -88,7 +88,7 @@
     src: "upstart.limits.conf.j2"
     dest: "/etc/security/limits.conf"
   when:
-    - pid1_name != "systemd"
+    - ansible_service_mgr == 'systemd'
   notify:
     - Restart mysql
   tags:
@@ -102,7 +102,7 @@
     owner: "root"
     mode: "0755"
   when:
-    - pid1_name == "systemd"
+    - ansible_service_mgr == 'systemd'
 
 - name: Apply resource limits (systemd)
   template:
@@ -110,7 +110,7 @@
     dest: "/etc/systemd/system/mariadb.service.d/limits.conf"
     mode: "0644"
   when:
-    - pid1_name == "systemd"
+    - ansible_service_mgr == 'systemd'
   notify:
     - Reload the systemd daemon
     - Restart mysql
diff --git a/tasks/main.yml b/tasks/main.yml
index 2743f963..c588e595 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -36,19 +36,6 @@
   tags:
     - always
 
-- 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
-
 - include: galera_upgrade_check.yml
 - include: galera_cluster_state.yml
 - include: galera_pre_install.yml