From 9eed0ea4e7aed94b0c354b62e54e0084ea7f0404 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Wed, 4 May 2016 12:16:27 -0500 Subject: [PATCH] Adds an use_systemd fact This adds a helper fact that uses the ``init_system`` fact to determine if we should be using systemd or not when controlling services. Signed-off-by: Andrew Schoen --- roles/ceph-common/handlers/main.yml | 13 +++++++++---- roles/ceph-common/tasks/facts.yml | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/roles/ceph-common/handlers/main.yml b/roles/ceph-common/handlers/main.yml index ca7102645..3b4ba2f5f 100644 --- a/roles/ceph-common/handlers/main.yml +++ b/roles/ceph-common/handlers/main.yml @@ -17,7 +17,7 @@ state: restarted when: socket.rc == 0 and - ansible_distribution != 'Ubuntu' and + use_systemd and mon_group_name in group_names and is_after_hammer @@ -26,6 +26,7 @@ when: socket.rc == 0 and ansible_distribution == 'Ubuntu' and + not use_systemd and mon_group_name in group_names - name: restart ceph osds @@ -45,7 +46,7 @@ state: restarted when: socket.rc == 0 and - ansible_distribution != 'Ubuntu' and + use_systemd and osd_group_name in group_names and is_after_hammer @@ -57,6 +58,7 @@ when: socket.rc == 0 and ansible_distribution == 'Ubuntu' and + not use_systemd and osd_group_name in group_names - name: restart ceph mdss on ubuntu @@ -64,6 +66,7 @@ when: socket.rc == 0 and ansible_distribution == 'Ubuntu' and + not use_systemd and mds_group_name in group_names - name: restart ceph mdss @@ -71,6 +74,7 @@ when: socket.rc == 0 and ansible_distribution != 'Ubuntu' and + not use_systemd and mds_group_name in group_names and ceph_stable and ceph_stable_release in ceph_stable_releases @@ -81,7 +85,7 @@ state: restarted when: socket.rc == 0 and - ansible_distribution != 'Ubuntu' and + use_systemd and mds_group_name in group_names and ceph_stable and ceph_stable_release not in ceph_stable_releases @@ -91,6 +95,7 @@ when: socketrgw.rc == 0 and ansible_distribution == 'Ubuntu' and + not use_systemd and rgw_group_name in group_names - name: restart ceph rgws @@ -115,7 +120,7 @@ state: restarted when: socketrgw.rc == 0 and - ansible_distribution != 'Ubuntu' and + use_systemd and rgw_group_name in group_names and is_after_hammer diff --git a/roles/ceph-common/tasks/facts.yml b/roles/ceph-common/tasks/facts.yml index 14367819a..427dc804d 100644 --- a/roles/ceph-common/tasks/facts.yml +++ b/roles/ceph-common/tasks/facts.yml @@ -17,6 +17,9 @@ - set_fact: init_system={{ init_system.content | b64decode }} +- set_fact: + use_systemd={{ init_system == 'systemd\n' }} + # NOTE (leseb/jsaintrocc): You are supposed to quote variables # that follow colons to avoid confusion with dicts but this # causes issues with the boolean, so we keep this syntax styling...