From 79dfd96a4ca4a41e395310c6b62d5bdf6130ef56 Mon Sep 17 00:00:00 2001 From: Logan V Date: Wed, 9 Nov 2016 22:31:18 -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: I82e3284b1d46d32ec28502ac4fe1a322316ca019 (cherry picked from commit bfce0b8a6010e5854daa0a98e579d3e2960b7c31) --- handlers/main.yml | 2 +- tasks/main.yml | 12 ------------ tasks/memcached_config.yml | 6 +++--- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 68cc747..0279006 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 memcached service: diff --git a/tasks/main.yml b/tasks/main.yml index ac32372..a384b97 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,18 +24,6 @@ tags: - always -- name: Check init system - command: cat /proc/1/comm - register: _pid1_name - tags: - - always - -- name: Set the name of pid1 - set_fact: - pid1_name: "{{ _pid1_name.stdout }}" - tags: - - always - - include: memcached_install.yml tags: - memcached-install diff --git a/tasks/memcached_config.yml b/tasks/memcached_config.yml index 67f489a..cebad26 100644 --- a/tasks/memcached_config.yml +++ b/tasks/memcached_config.yml @@ -48,7 +48,7 @@ owner: "root" mode: "0755" when: - - pid1_name == "systemd" + - ansible_service_mgr == 'systemd' - name: Apply resource limits (upstart) template: @@ -59,7 +59,7 @@ mode: "0644" when: - ansible_pkg_mgr == 'apt' - - pid1_name != "systemd" + - ansible_service_mgr != 'systemd' - memcached_connections > 1024 notify: Restart memcached @@ -71,7 +71,7 @@ group: "root" mode: "0644" when: - - pid1_name == "systemd" + - ansible_service_mgr == 'systemd' - memcached_connections > 1024 notify: - Reload the systemd daemon