2014-04-11 22:34:33 +08:00
|
|
|
---
|
|
|
|
# This playbook purges Ceph
|
|
|
|
# It removes: packages, configuration files and ALL THE DATA
|
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: stop ceph cluster
|
|
|
|
hosts:
|
|
|
|
- mons
|
|
|
|
- osds
|
|
|
|
- mdss
|
2016-02-28 19:53:31 +08:00
|
|
|
- rgws
|
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
become: yes
|
|
|
|
|
2016-02-28 19:53:31 +08:00
|
|
|
roles:
|
|
|
|
- ceph-common
|
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
vars:
|
|
|
|
# When set to true both groups of packages are purged.
|
2016-02-15 23:01:00 +08:00
|
|
|
# This can cause problem with qemu-kvm
|
2016-02-10 20:13:39 +08:00
|
|
|
purge_all_packages: true
|
|
|
|
|
2016-02-29 20:19:56 +08:00
|
|
|
# When set to true and raw _multi_journal is used then journal disk are also zapped
|
|
|
|
zap_journal_disks: true
|
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
ceph_packages:
|
|
|
|
- ceph
|
|
|
|
- ceph-common
|
|
|
|
- ceph-fs-common
|
|
|
|
- ceph-fuse
|
|
|
|
- ceph-mds
|
|
|
|
- ceph-release
|
2016-02-28 19:53:31 +08:00
|
|
|
- ceph-radosgw
|
2016-02-10 20:13:39 +08:00
|
|
|
|
|
|
|
ceph_remaining_packages:
|
|
|
|
- libcephfs1
|
|
|
|
- librados2
|
|
|
|
- libradosstriper1
|
|
|
|
- librbd1
|
|
|
|
- python-cephfs
|
|
|
|
- python-rados
|
|
|
|
- python-rbd
|
|
|
|
|
2014-04-11 22:34:33 +08:00
|
|
|
|
2015-10-21 06:32:42 +08:00
|
|
|
tasks:
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: get osd numbers
|
|
|
|
shell: ls /var/lib/ceph/osd | cut -d "-" -f 2
|
|
|
|
register: osd_ids
|
|
|
|
changed_when: false
|
|
|
|
when:
|
|
|
|
osd_group_name in group_names
|
2015-10-21 06:32:42 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
# Infernalis
|
|
|
|
- name: stop ceph.target with systemd
|
|
|
|
service:
|
|
|
|
name: ceph.target
|
|
|
|
state: stopped
|
|
|
|
enabled: no
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_os_family == 'RedHat' and
|
2016-02-10 20:13:39 +08:00
|
|
|
ceph_stable_release == 'infernalis'
|
2015-10-21 06:32:42 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: stop ceph-osd with systemd
|
|
|
|
service:
|
|
|
|
name: ceph-osd@{{item}}
|
|
|
|
state: stopped
|
|
|
|
enabled: no
|
|
|
|
with_items: "{{ osd_ids.stdout_lines }}"
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_os_family == 'RedHat' and
|
2016-02-10 20:13:39 +08:00
|
|
|
ceph_stable_release == 'infernalis' and
|
|
|
|
osd_group_name in group_names
|
2015-10-21 06:32:42 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: stop ceph mons with systemd
|
|
|
|
service:
|
|
|
|
name: ceph-mon@{{ ansible_hostname }}
|
|
|
|
state: stopped
|
|
|
|
enabled: no
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_os_family == 'RedHat' and
|
2016-02-10 20:13:39 +08:00
|
|
|
ceph_stable_release == 'infernalis' and
|
|
|
|
mon_group_name in group_names
|
2015-10-21 06:32:42 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: stop ceph mdss with systemd
|
|
|
|
service:
|
|
|
|
name: ceph-mds@{{ ansible_hostname }}
|
|
|
|
state: stopped
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_os_family == 'RedHat' and
|
2016-02-10 20:13:39 +08:00
|
|
|
ceph_stable_release == 'infernalis' and
|
|
|
|
mds_group_name in group_names
|
2015-10-21 06:32:42 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
# before infernalis
|
|
|
|
- name: stop ceph osds
|
|
|
|
command: service ceph stop osd
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_os_family == 'RedHat' and
|
2016-02-10 20:13:39 +08:00
|
|
|
osd_group_name in group_names and
|
|
|
|
ceph_stable_release != 'infernalis'
|
2014-08-14 20:08:52 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: stop ceph mons
|
|
|
|
command: service ceph stop mon
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_os_family == 'RedHat' and
|
2016-02-10 20:13:39 +08:00
|
|
|
mon_group_name in group_names and
|
|
|
|
ceph_stable_release != 'infernalis'
|
2014-04-11 22:34:33 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: stop ceph mdss
|
|
|
|
command: service ceph stop mds
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_os_family == 'RedHat' and
|
2016-02-10 20:13:39 +08:00
|
|
|
mds_group_name in group_names and
|
|
|
|
ceph_stable_release != 'infernalis'
|
|
|
|
|
|
|
|
# Ubuntu 14.04
|
|
|
|
- name: stop ceph osds on ubuntu
|
|
|
|
command: stop ceph-osd-all
|
2015-07-29 00:21:15 +08:00
|
|
|
failed_when: false
|
2016-02-10 20:13:39 +08:00
|
|
|
when:
|
|
|
|
ansible_distribution == 'Ubuntu' and
|
|
|
|
osd_group_name in group_names
|
2015-07-08 16:34:16 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: stop ceph mons on ubuntu
|
|
|
|
command: stop ceph-mon-all
|
|
|
|
failed_when: false
|
|
|
|
when:
|
|
|
|
ansible_distribution == 'Ubuntu' and
|
|
|
|
mon_group_name in group_names
|
|
|
|
|
|
|
|
- name: stop ceph mdss on ubuntu
|
|
|
|
command: stop ceph-mds-all
|
2015-07-29 00:21:15 +08:00
|
|
|
failed_when: false
|
2016-02-10 20:13:39 +08:00
|
|
|
when:
|
|
|
|
ansible_distribution == 'Ubuntu' and
|
|
|
|
mds_group_name in group_names
|
|
|
|
|
|
|
|
# rc is 2 if file not found, so no mount point, so no error
|
|
|
|
- name: get osd data mount points
|
|
|
|
shell: ls /var/lib/ceph/osd
|
|
|
|
register: mounted_osd
|
|
|
|
changed_when: false
|
|
|
|
failed_when: mounted_osd.rc != 0 and mounted_osd.rc != 2
|
|
|
|
when:
|
|
|
|
osd_group_name in group_names
|
|
|
|
|
|
|
|
- name: umount osd data partition
|
|
|
|
shell: umount /var/lib/ceph/osd/{{ item }}
|
|
|
|
failed_when: false
|
|
|
|
with_items:
|
|
|
|
- "{{ mounted_osd.stdout_lines }}"
|
|
|
|
when:
|
|
|
|
osd_group_name in group_names
|
|
|
|
|
|
|
|
- name: zap osd disks
|
|
|
|
shell: ceph-disk zap "{{ item }}"
|
|
|
|
with_items: devices
|
|
|
|
when:
|
|
|
|
osd_group_name in group_names
|
|
|
|
|
2016-02-29 20:19:56 +08:00
|
|
|
- name: zap journal devices
|
|
|
|
shell: ceph-disk zap "{{ item }}"
|
|
|
|
with_items: "{{ raw_journal_devices|default([])|unique }}"
|
|
|
|
when:
|
|
|
|
osd_group_name in group_names and
|
|
|
|
raw_multi_journal and
|
|
|
|
zap_journal_disks
|
|
|
|
|
2016-02-15 23:01:00 +08:00
|
|
|
- name: purge ceph packages with yum
|
|
|
|
yum:
|
2016-02-10 20:13:39 +08:00
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- "{{ ceph_packages }}"
|
2016-02-15 23:01:00 +08:00
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_pkg_mgr == 'yum'
|
|
|
|
|
|
|
|
- name: purge ceph packages with dnf
|
|
|
|
dnf:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- "{{ ceph_packages }}"
|
|
|
|
when:
|
|
|
|
ansible_pkg_mgr == 'dnf'
|
2016-02-10 20:13:39 +08:00
|
|
|
|
2016-02-15 23:01:00 +08:00
|
|
|
- name: purge ceph packages with apt
|
|
|
|
apt:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- "{{ ceph_packages }}"
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_pkg_mgr == 'apt'
|
2016-02-15 23:01:00 +08:00
|
|
|
|
|
|
|
- name: purge remaining ceph packages with yum
|
|
|
|
yum:
|
2016-02-10 20:13:39 +08:00
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- "{{ ceph_remaining_packages }}"
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_pkg_mgr == 'yum' and
|
|
|
|
purge_all_packages == true
|
|
|
|
|
|
|
|
- name: purge remaining ceph packages with dnf
|
|
|
|
dnf:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- "{{ ceph_remaining_packages }}"
|
|
|
|
when:
|
|
|
|
ansible_pkg_mgr == 'dnf' and
|
2016-02-15 23:01:00 +08:00
|
|
|
purge_all_packages == true
|
|
|
|
|
|
|
|
- name: purge remaining ceph packages with apt
|
|
|
|
apt:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- "{{ ceph_remaining_packages }}"
|
|
|
|
when:
|
2016-02-15 23:51:16 +08:00
|
|
|
ansible_pkg_mgr == 'apt' and
|
2016-02-10 20:13:39 +08:00
|
|
|
purge_all_packages == true
|
|
|
|
|
|
|
|
- name: remove config
|
|
|
|
file:
|
|
|
|
path: /etc/ceph
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: remove data
|
|
|
|
file:
|
|
|
|
path: /var/lib/ceph
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: remove logs
|
|
|
|
file:
|
|
|
|
path: /var/log/ceph
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: remove form SysV
|
|
|
|
shell: "update-rc.d -f ceph remove"
|
|
|
|
when:
|
|
|
|
ansible_distribution == 'Ubuntu'
|
|
|
|
|
|
|
|
- name: remove Upstart nad SysV files
|
2016-02-16 20:41:58 +08:00
|
|
|
shell: "find /etc -name '*ceph*' -delete"
|
2016-02-10 20:13:39 +08:00
|
|
|
when:
|
|
|
|
ansible_distribution == 'Ubuntu'
|
2015-07-08 16:34:16 +08:00
|
|
|
|
2016-02-10 20:13:39 +08:00
|
|
|
- name: remove Upstart and apt logs and cache
|
2016-02-16 20:41:58 +08:00
|
|
|
shell: "find /var -name '*ceph*' -delete"
|
2016-02-10 20:13:39 +08:00
|
|
|
when:
|
2016-02-16 20:41:58 +08:00
|
|
|
ansible_distribution == 'Ubuntu'
|