purge_cluster: wipe all partitions

In order to ensure there is no leftover after having purged a cluster,
we must wipe all partitions properly.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1492242

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/2609/head
Guillaume Abrioux 2018-05-16 17:34:38 +02:00 committed by Sébastien Han
parent 9cad113e2f
commit a9247c4de7
1 changed files with 11 additions and 3 deletions

View File

@ -388,17 +388,25 @@
set_fact: set_fact:
resolved_parent_device: "{{ tmp_resolved_parent_device.results | map(attribute='stdout') | list | unique }}" resolved_parent_device: "{{ tmp_resolved_parent_device.results | map(attribute='stdout') | list | unique }}"
- name: wipe partitions
shell: |
wipefs --all "{{ item }}"
dd if=/dev/zero of="{{ item }}" bs=1 count=4096
with_items: "{{ combined_devices_list }}"
- name: zap ceph journal/block db/block wal partitions - name: zap ceph journal/block db/block wal partitions
shell: | shell: |
# if the disk passed is a raw device AND the boot system disk # if the disk passed is a raw device AND the boot system disk
if parted -s "/dev/{{ item }}" print | grep -sq boot; then if parted -s /dev/"{{ item }}" print | grep -sq boot; then
echo "Looks like /dev/{{ item }} has a boot partition," echo "Looks like /dev/{{ item }} has a boot partition,"
echo "if you want to delete specific partitions point to the partition instead of the raw device" echo "if you want to delete specific partitions point to the partition instead of the raw device"
echo "Do not use your system disk!" echo "Do not use your system disk!"
exit 1 exit 1
fi fi
sgdisk -Z "/dev/{{ item }}" sgdisk -Z --clear --mbrtogpt -g -- /dev/"{{ item }}"
dd if=/dev/zero of="/dev/{{ item }}" bs=1M count=200 dd if=/dev/zero of=/dev/"{{ item }}" bs=1M count=200
parted -s /dev/"{{ item }}" mklabel gpt
partprobe /dev/"{{ item }}"
udevadm settle --timeout=600 udevadm settle --timeout=600
with_items: with_items:
- "{{ resolved_parent_device }}" - "{{ resolved_parent_device }}"