2024-02-14 18:14:02 +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:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: ireallymeanit # noqa: name[casing]
|
2018-07-24 21:33:09 +08:00
|
|
|
prompt: Are you sure you want to tear down the logical volumes?
|
|
|
|
default: 'no'
|
2024-02-14 18:14:02 +08:00
|
|
|
private: false
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Exit playbook, if user did not mean to tear down logical volumes
|
|
|
|
ansible.builtin.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'
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Include vars of lv_vars.yaml
|
|
|
|
ansible.builtin.include_vars:
|
|
|
|
file: lv_vars.yaml # noqa missing-import
|
|
|
|
failed_when: false
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
# need to check if lvm2 is installed
|
|
|
|
- name: Install lvm2
|
|
|
|
ansible.builtin.package:
|
|
|
|
name: lvm2
|
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
2018-07-24 21:33:09 +08:00
|
|
|
|
|
|
|
# BEGIN TEARDOWN
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Find any existing osd filesystems
|
|
|
|
ansible.builtin.shell: |
|
|
|
|
set -o pipefail;
|
|
|
|
grep /var/lib/ceph/osd /proc/mounts | awk '{print $2}'
|
|
|
|
register: old_osd_filesystems
|
|
|
|
changed_when: false
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Tear down any existing osd filesystem
|
|
|
|
ansible.posix.mount:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: unmounted
|
|
|
|
with_items: "{{ old_osd_filesystems.stdout_lines }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Kill all lvm commands that may have been hung
|
|
|
|
ansible.builtin.command: "killall -q lvcreate pvcreate vgcreate lvconvert || echo -n"
|
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
## Logcal Vols
|
|
|
|
- name: Tear down existing lv for bucket index
|
|
|
|
community.general.lvol:
|
|
|
|
lv: "{{ item.lv_name }}"
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
|
|
|
state: absent
|
|
|
|
force: true
|
|
|
|
with_items: "{{ nvme_device_lvs }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Tear down any existing hdd data lvs
|
|
|
|
community.general.lvol:
|
|
|
|
lv: "{{ hdd_lv_prefix }}-{{ item.split('/')[-1] }}"
|
|
|
|
vg: "{{ hdd_vg_prefix }}-{{ item.split('/')[-1] }}"
|
|
|
|
state: absent
|
|
|
|
force: true
|
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Tear down any existing lv of journal for bucket index
|
|
|
|
community.general.lvol:
|
|
|
|
lv: "{{ item.journal_name }}"
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
|
|
|
state: absent
|
|
|
|
force: true
|
|
|
|
with_items: "{{ nvme_device_lvs }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Tear down any existing lvs of hdd journals
|
|
|
|
community.general.lvol:
|
|
|
|
lv: "{{ hdd_journal_prefix }}-{{ item.split('/')[-1] }}"
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
|
|
|
state: absent
|
|
|
|
force: true
|
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
## Volume Groups
|
|
|
|
- name: Remove vg on nvme device
|
|
|
|
community.general.lvg:
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
|
|
|
state: absent
|
|
|
|
force: true
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Remove vg for each hdd device
|
|
|
|
community.general.lvg:
|
|
|
|
vg: "{{ hdd_vg_prefix }}-{{ item.split('/')[-1] }}"
|
|
|
|
state: absent
|
|
|
|
force: true
|
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
## Physical Vols
|
|
|
|
- name: Tear down pv for nvme device
|
|
|
|
ansible.builtin.command: "pvremove --force --yes {{ nvme_device }}"
|
|
|
|
changed_when: false
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Tear down pv for each hdd device
|
|
|
|
ansible.builtin.command: "pvremove --force --yes {{ item }}"
|
|
|
|
changed_when: false
|
|
|
|
with_items: "{{ hdd_devices }}"
|