purge-cluster: do not use ceph-detect-init

We can not always ensure that ceph-detect-init will be
present on the system.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1418980

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
pull/1284/head
Andrew Schoen 2017-02-07 11:57:38 -06:00
parent 0617f92df5
commit 0476b24af1
1 changed files with 21 additions and 23 deletions

View File

@ -31,7 +31,7 @@
invoking the playbook"
when: ireallymeanit != 'yes'
- name: gather facts and check init system
- name: gather facts on all hosts
vars:
mon_group_name: mons
@ -54,9 +54,7 @@
become: true
tasks:
- name: detect init system
command: ceph-detect-init
register: init_system
- debug: msg="gather facts on all Ceph hosts for following reference"
- name: purge ceph mds cluster
@ -83,16 +81,16 @@
name: ceph-mds@{{ ansible_hostname }}
state: stopped
enabled: no
when: init_system.stdout == 'systemd'
when: ansible_service_mgr == 'systemd'
- name: stop ceph mdss
shell: "service ceph status mds ; if [ $? == 0 ] ; then service ceph stop mds ; else echo ; fi"
when: init_system.stdout == 'sysvinit'
when: ansible_service_mgr == 'sysvinit'
- name: stop ceph mdss on ubuntu
command: initctl stop ceph-mds cluster={{ cluster }} id={{ ansible_hostname }}
failed_when: false
when: init_system.stdout == 'upstart'
when: ansible_service_mgr == 'upstart'
- name: purge ceph rgw cluster
@ -120,16 +118,16 @@
name: ceph-radosgw@rgw.{{ ansible_hostname }}
state: stopped
enabled: no
when: init_system.stdout == 'systemd'
when: ansible_service_mgr == 'systemd'
- name: stop ceph rgws
shell: "service ceph-radosgw status ; if [ $? == 0 ] ; then service ceph-radosgw stop ; else echo ; fi"
when: init_system.stdout == 'sysvinit'
when: ansible_service_mgr == 'sysvinit'
- name: stop ceph rgws on ubuntu
command: initctl stop radosgw cluster={{ cluster }} id={{ ansible_hostname }}
failed_when: false
when: init_system.stdout == 'upstart'
when: ansible_service_mgr == 'upstart'
- name: purge ceph rbd-mirror cluster
@ -156,12 +154,12 @@
service:
name: ceph-rbd-mirror@admin.service
state: stopped
when: init_system.stdout == 'systemd'
when: ansible_service_mgr == 'systemd'
- name: stop ceph rbd mirror on ubuntu
command: initctl stop ceph-rbd-mirror cluster={{ cluster }} id=admin
failed_when: false
when: init_system.stdout == 'upstart'
when: ansible_service_mgr == 'upstart'
- name: purge ceph nfs cluster
@ -188,16 +186,16 @@
service:
name: nfs-ganesha
state: stopped
when: init_system.stdout == 'systemd'
when: ansible_service_mgr == 'systemd'
- name: stop ceph nfss
shell: "service nfs-ganesha status ; if [ $? == 0 ] ; then service nfs-ganesha stop ; else echo ; fi"
when: init_system.stdout == 'sysvinit'
when: ansible_service_mgr == 'sysvinit'
- name: stop ceph nfss on ubuntu
command: initctl stop nfs-ganesha
failed_when: false
when: init_system.stdout == 'upstart'
when: ansible_service_mgr == 'upstart'
- name: purge ceph osd cluster
@ -252,7 +250,7 @@
state: stopped
enabled: no
with_items: "{{ osd_ids.stdout_lines }}"
when: init_system.stdout == 'systemd'
when: ansible_service_mgr == 'systemd'
# before infernalis release, using sysvinit scripts
# we use this test so we do not have to know which RPM contains the boot script
@ -260,7 +258,7 @@
- name: stop ceph osds
shell: "service ceph status osd ; if [ $? == 0 ] ; then service ceph stop osd ; else echo ; fi"
when: init_system.stdout == 'sysvinit'
when: ansible_service_mgr == 'sysvinit'
- name: stop ceph osds on ubuntu
shell: |
@ -268,7 +266,7 @@
initctl stop ceph-osd cluster={{ cluster }} id=$id
done
failed_when: false
when: init_system.stdout == 'upstart'
when: ansible_service_mgr == 'upstart'
with_items: "{{ osd_ids.stdout_lines }}"
- name: see if ceph-disk-created data partitions are present
@ -412,16 +410,16 @@
name: ceph-mon@{{ ansible_hostname }}
state: stopped
enabled: no
when: init_system.stdout == 'systemd'
when: ansible_service_mgr == 'systemd'
- name: stop ceph mons
shell: "service ceph status mon ; if [ $? == 0 ] ; then service ceph stop mon ; else echo ; fi"
when: init_system.stdout == 'sysvinit'
when: ansible_service_mgr == 'sysvinit'
- name: stop ceph mons on ubuntu
command: initctl stop ceph-mon cluster={{ cluster }} id={{ ansible_hostname }}
failed_when: false
when: init_system.stdout == 'upstart'
when: ansible_service_mgr == 'upstart'
- name: remove monitor store and bootstrap keys
file:
@ -555,11 +553,11 @@
- name: remove from sysv
shell: "update-rc.d -f ceph remove"
when: init_system.stdout == 'sysvinit'
when: ansible_service_mgr == 'sysvinit'
- name: remove upstart and sysv files
shell: "find /etc -name '*ceph*' -delete"
when: init_system.stdout == 'upstart'
when: ansible_service_mgr == 'upstart'
- name: remove upstart and apt logs and cache
shell: "find /var -name '*ceph*' -delete"