]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
rolling-update: detect init system properly 1289/head
authorSébastien Han <seb@redhat.com>
Tue, 7 Feb 2017 21:37:29 +0000 (22:37 +0100)
committerSébastien Han <seb@redhat.com>
Wed, 8 Feb 2017 07:52:05 +0000 (08:52 +0100)
Simply use the ansible_service_mgr fact.

Closes: #1286
Signed-off-by: Sébastien Han <seb@redhat.com>
infrastructure-playbooks/rolling_update.yml

index 589601a67517886a6208cf112d607d165d3d7df1..9623d392ce482d2ae91d136719db1b508cf268ca 100644 (file)
 
     - set_fact: rolling_update=true
 
-    - name: check if sysvinit
-      stat:
-        path: /etc/rc?.d/S??ceph
-        follow: yes
-      register: is_sysvinit
-
-    - name: check if upstart
-      stat:
-        path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/upstart
-      register: is_upstart
-
-    - name: check if systemd
-      command: grep -sq systemd /proc/1/comm
-      register: is_systemd
-
-
 - name: upgrade ceph mon cluster
 
   vars:
         name: ceph-mon
         state: stopped
         args: id={{ ansible_hostname }}
-      when: is_upstart.stat.exists == True
+      when: ansible_service_mgr == 'systemd'
 
     - name: stop ceph mons with sysvinit
       service:
         name: ceph
         state: stopped
-      when: is_sysvinit.stat.exists == True
+      when: ansible_service_mgr == 'sysvinit'
 
     - name: stop ceph mons with systemd
       service:
         state: stopped
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - not mon_containerized_deployment
 
   roles:
         name: ceph-mon
         state: started
         args: id={{ ansible_hostname }}
-      when: is_upstart.stat.exists == True
+      when: ansible_service_mgr == 'upstart'
 
     - name: start ceph mons with sysvinit
       service:
         name: ceph
         state: started
-      when: is_sysvinit.stat.exists == True
+      when: ansible_service_mgr == 'sysvinit'
 
     - name: start ceph mons with systemd
       service:
         state: started
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - not mon_containerized_deployment
 
     - name: restart containerized ceph mons with systemd
         state: restarted
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - mon_containerized_deployment
 
     - name: set mon_host_count
       service:
         name: ceph-osd-all
         state: stopped
-      when: is_upstart.stat.exists == True
+      when: ansible_service_mgr == 'upstart'
 
     - name: stop ceph osds with sysvinit
       service:
         name: ceph
         state: stopped
-      when: is_sysvinit.stat.exists == True
+      when: ansible_service_mgr == 'sysvinit'
 
     - name: stop ceph osds with systemd
       service:
         enabled: yes
       with_items: "{{ osd_ids.stdout_lines }}"
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - not osd_containerized_deployment
 
   roles:
       service:
         name: ceph-osd-all
         state: started
-      when: is_upstart.stat.exists == True
+      when: ansible_service_mgr == 'upstart'
 
     - name: start ceph osds with sysvinit
       service:
         name: ceph
         state: started
-      when: is_sysvinit.stat.exists == True
+      when: ansible_service_mgr == 'sysvinit'
 
     - name: start ceph osds with systemd
       service:
         enabled: yes
       with_items: "{{ osd_ids.stdout_lines }}"
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - not osd_containerized_deployment
 
     - name: restart containerized ceph osds with systemd
         enabled: yes
       with_items: "{{ ceph_osd_docker_devices }}"
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - osd_containerized_deployment
 
     - name: waiting for clean pgs...
         name: ceph-mds
         state: stopped
         args: id={{ ansible_hostname }}
-      when: is_upstart.stat.exists == True
+      when: ansible_service_mgr == 'upstart'
 
     - name: stop ceph mdss with sysvinit
       service:
         name: ceph
         state: stopped
         args: mds
-      when: is_sysvinit.stat.exists == True
+      when: ansible_service_mgr == 'sysvinit'
 
     - name: stop ceph mdss with systemd
       service:
         state: stopped
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - not mds_containerized_deployment
 
   roles:
         name: ceph-mds
         state: started
         args: id={{ ansible_hostname }}
-      when: is_upstart.stat.exists == True
+      when: ansible_service_mgr == 'upstart'
 
     - name: start ceph mdss with sysvinit
       service:
         name: ceph
         state: started
         args: mds
-      when: is_sysvinit.stat.exists == True
+      when: ansible_service_mgr == 'sysvinit'
 
     - name: start ceph mdss with systemd
       service:
         state: started
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - not mds_containerized_deployment
 
     - name: restart ceph mdss
         state: restarted
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - mds_containerized_deployment
 
 
       service:
         name: ceph-radosgw
         state: stopped
-      when: is_upstart.stat.exists == True
+      when: ansible_service_mgr == 'upstart'
 
     - name: stop ceph rgws with sysvinit
       service:
         name: radosgw
         state: stopped
-      when: is_sysvinit.stat.exists == True
+      when: ansible_service_mgr == 'sysvinit'
 
     - name: stop ceph rgws with systemd
       service:
         state: stopped
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - not rgw_containerized_deployment
 
   roles:
       service:
         name: ceph-radosgw
         state: started
-      when: is_upstart.stat.exists == True
+      when: ansible_service_mgr == 'upstart'
 
     - name: start ceph rgws with sysvinit
       service:
         name: radosgw
         state: started
-      when: is_sysvinit.stat.exists == True
+      when: ansible_service_mgr == 'sysvinit'
 
     - name: start ceph rgws with systemd
       service:
         state: started
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - not rgw_containerized_deployment
 
     - name: restart containerized ceph rgws with systemd
         state: restarted
         enabled: yes
       when:
-        - is_systemd
+        - ansible_service_mgr == 'systemd'
         - rgw_containerized_deployment