2018-07-24 21:33:09 +08:00
|
|
|
- name: tear down existing osd filesystems then logical volumes, volume groups, and physical volumes
|
2018-08-09 06:04:07 +08:00
|
|
|
become: true
|
2019-04-01 23:46:15 +08:00
|
|
|
hosts: osds
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
vars_prompt:
|
|
|
|
- name: ireallymeanit
|
|
|
|
prompt: Are you sure you want to tear down the logical volumes?
|
|
|
|
default: 'no'
|
|
|
|
private: no
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: exit playbook, if user did not mean to tear down logical volumes
|
|
|
|
fail:
|
|
|
|
msg: >
|
|
|
|
"Exiting lv-teardown playbook, logical volumes were NOT torn down.
|
|
|
|
To tear down the logical volumes, either say 'yes' on the prompt or
|
|
|
|
or use `-e ireallymeanit=yes` on the command line when
|
|
|
|
invoking the playbook"
|
|
|
|
when: ireallymeanit != 'yes'
|
|
|
|
|
|
|
|
- name: include vars of lv_vars.yaml
|
|
|
|
include_vars:
|
|
|
|
file: lv_vars.yaml
|
2018-08-09 06:04:29 +08:00
|
|
|
failed_when: false
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
# need to check if lvm2 is installed
|
|
|
|
- name: install lvm2
|
|
|
|
package:
|
|
|
|
name: lvm2
|
|
|
|
state: present
|
2018-12-19 21:55:01 +08:00
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
# BEGIN TEARDOWN
|
|
|
|
- name: find any existing osd filesystems
|
2020-10-02 17:23:42 +08:00
|
|
|
shell: |
|
|
|
|
set -o pipefail;
|
|
|
|
grep /var/lib/ceph/osd /proc/mounts | awk '{print $2}'
|
2018-07-24 21:33:09 +08:00
|
|
|
register: old_osd_filesystems
|
|
|
|
|
|
|
|
- name: tear down any existing osd filesystems
|
|
|
|
command: "umount -v {{ item }}"
|
|
|
|
with_items: "{{ old_osd_filesystems.stdout_lines }}"
|
|
|
|
|
|
|
|
- name: kill all lvm commands that may have been hung
|
|
|
|
command: "killall -q lvcreate pvcreate vgcreate lvconvert || echo -n"
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
## Logcal Vols
|
|
|
|
- name: tear down existing lv for bucket index
|
|
|
|
lvol:
|
2018-08-04 04:08:31 +08:00
|
|
|
lv: "{{ item.lv_name }}"
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
state: absent
|
|
|
|
force: yes
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ nvme_device_lvs }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
- name: tear down any existing hdd data lvs
|
|
|
|
lvol:
|
|
|
|
lv: "{{ hdd_lv_prefix }}-{{ item.split('/')[-1] }}"
|
2018-08-04 04:08:31 +08:00
|
|
|
vg: "{{ hdd_vg_prefix }}-{{ item.split('/')[-1] }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
state: absent
|
|
|
|
force: yes
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
- name: tear down any existing lv of journal for bucket index
|
|
|
|
lvol:
|
2018-08-04 04:08:31 +08:00
|
|
|
lv: "{{ item.journal_name }}"
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
state: absent
|
|
|
|
force: yes
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ nvme_device_lvs }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
- name: tear down any existing lvs of hdd journals
|
|
|
|
lvol:
|
|
|
|
lv: "{{ hdd_journal_prefix }}-{{ item.split('/')[-1] }}"
|
2018-08-04 04:08:31 +08:00
|
|
|
vg: "{{ nvme_vg_name }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
state: absent
|
|
|
|
force: yes
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
## Volume Groups
|
|
|
|
- name: remove vg on nvme device
|
|
|
|
lvg:
|
2018-08-04 04:08:31 +08:00
|
|
|
vg: "{{ nvme_vg_name }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
state: absent
|
|
|
|
force: yes
|
|
|
|
|
|
|
|
- name: remove vg for each hdd device
|
|
|
|
lvg:
|
2018-08-04 04:08:31 +08:00
|
|
|
vg: "{{ hdd_vg_prefix }}-{{ item.split('/')[-1] }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
state: absent
|
|
|
|
force: yes
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
## Physical Vols
|
|
|
|
- name: tear down pv for nvme device
|
|
|
|
command: "pvremove --force --yes {{ nvme_device }}"
|
|
|
|
|
|
|
|
- name: tear down pv for each hdd device
|
|
|
|
command: "pvremove --force --yes {{ item }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ hdd_devices }}"
|