From ed2b7757d43ba7af96d97a9f345aba38e4410bd2 Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Wed, 4 May 2016 11:47:24 +0100 Subject: [PATCH] Set init_system fact and reference in ceph-osd role The ceph-osd role currently uses ansible_service_mgr, which is a fact only available on ansible 2.x and greater. This commit sets a similar fact called init_system which will store the contents of /proc/1/comm (systemd, init, etc.) and then references it ceph-osd instead. Closes #741 --- roles/ceph-common/tasks/facts.yml | 9 +++++++++ roles/ceph-osd/tasks/scenarios/osd_directory.yml | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/roles/ceph-common/tasks/facts.yml b/roles/ceph-common/tasks/facts.yml index 240305b55..14367819a 100644 --- a/roles/ceph-common/tasks/facts.yml +++ b/roles/ceph-common/tasks/facts.yml @@ -8,6 +8,15 @@ - set_fact: ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}" +# NOTE(mattt): On ansible 2.x we can use ansible_service_mgr instead +- name: check init system + slurp: + src: /proc/1/comm + register: init_system + +- set_fact: + init_system={{ init_system.content | b64decode }} + # 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... diff --git a/roles/ceph-osd/tasks/scenarios/osd_directory.yml b/roles/ceph-osd/tasks/scenarios/osd_directory.yml index 432f65872..a7447948e 100644 --- a/roles/ceph-osd/tasks/scenarios/osd_directory.yml +++ b/roles/ceph-osd/tasks/scenarios/osd_directory.yml @@ -31,11 +31,11 @@ name: ceph state: started enabled: yes - when: ansible_service_mgr != "systemd" + when: init_system != "systemd" - name: start and add the OSD target to the systemd sequence service: name: ceph.target state: started enabled: yes - when: ansible_service_mgr == "systemd" + when: init_system == "systemd"