feat: rook-ceph nuke playbook

This commit is contained in:
auricom
2021-04-20 00:22:36 +02:00
parent 91de3af89d
commit 0656a1fe1d
4 changed files with 66 additions and 0 deletions

View File

@@ -7,3 +7,9 @@ ansible_user: "ubuntu"
# ansible_ssh_pass: "ubuntu"
# ansible_ssh_common_args: "-o UserKnownHostsFile=/dev/null"
# ansible_become_pass: "ubuntu"
# Set enabled to true to mark this host as running a distributed storage rook-ceph
rook_ceph:
enabled: true
devices:
- /dev/nvme0n1

View File

@@ -7,3 +7,9 @@ ansible_user: "ubuntu"
# ansible_ssh_pass: "ubuntu"
# ansible_ssh_common_args: "-o UserKnownHostsFile=/dev/null"
# ansible_become_pass: "ubuntu"
# Set enabled to true to mark this host as running a distributed storage rook-ceph
rook_ceph:
enabled: true
devices:
- /dev/nvme0n1

View File

@@ -7,3 +7,9 @@ ansible_user: "ubuntu"
# ansible_ssh_pass: "ubuntu"
# ansible_ssh_common_args: "-o UserKnownHostsFile=/dev/null"
# ansible_become_pass: "ubuntu"
# Set enabled to true to mark this host as running a distributed storage rook-ceph
rook_ceph:
enabled: true
devices:
- /dev/nvme0n1

View File

@@ -0,0 +1,48 @@
---
- hosts:
- worker-nodes
become: true
gather_facts: true
any_errors_fatal: true
pre_tasks:
- name: Pausing for 5 seconds...
pause:
seconds: 5
tasks:
- name: remove /var/lib/rook
become: true
ansible.builtin.file:
state: absent
path: "/var/lib/rook"
when:
- rook_ceph.enabled is defined
- rook_ceph.enabled
- name: zap the drives
become: true
ansible.builtin.shell: >
sgdisk --zap-all {{ item }} || true
loop:
- "{{ rook_ceph.devices }}"
when:
- rook_ceph.enabled is defined
- rook_ceph.enabled
- name: remove lvm partitions
become: true
ansible.builtin.shell: "{{ item }}"
loop:
- ls /dev/mapper/ceph--* | xargs -I% -- fuser --kill %
- ls /dev/mapper/ceph--* | xargs -I% -- dmsetup clear %
- ls /dev/mapper/ceph--* | xargs -I% -- dmsetup remove -f %
- ls /dev/mapper/ceph--* | xargs -I% -- rm -rf %
when:
- rook_ceph.enabled is defined
- rook_ceph.enabled
- name: wipe the block device
become: true
ansible.builtin.command: "wipefs -af {{ item }}"
with_items:
- "{{ rook_ceph.devices }}"
when:
- rook_ceph.enabled is defined
- rook_ceph.enabled