From: Guillaume Abrioux Date: Fri, 18 May 2018 15:56:03 +0000 (+0200) Subject: purge_cluster: fix dmcrypt purge X-Git-Tag: v3.2.0beta1~91 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9801bde4d4ce501208fc297d5cb0ab2e0aa28702;p=ceph-ansible.git purge_cluster: fix dmcrypt purge dmcrypt devices aren't closed properly, therefore, it may fail when trying to redeploy after a purge. Typical errors: ``` ceph-disk: Cannot discover filesystem type: device /dev/sdb1: Command '/sbin/blkid' returned non-zero exit status 2 ``` ``` ceph-disk: Error: unable to read dm-crypt key: /var/lib/ceph/osd-lockbox/c6e01af1-ed8c-4d40-8be7-7fc0b4e104cf: /etc/ceph/dmcrypt-keys/c6e01af1-ed8c-4d40-8be7-7fc0b4e104cf.luks.key ``` Closing properly dmcrypt devices allows to redeploy without error. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1492242 Signed-off-by: Guillaume Abrioux --- diff --git a/infrastructure-playbooks/purge-cluster.yml b/infrastructure-playbooks/purge-cluster.yml index bcba8b05a..df741c842 100644 --- a/infrastructure-playbooks/purge-cluster.yml +++ b/infrastructure-playbooks/purge-cluster.yml @@ -311,11 +311,35 @@ failed_when: false register: ceph_disk_present + - name: wipe table on dm-crypt devices + command: dmsetup wipe_table --force "{{ item }}" + with_items: "{{ encrypted_ceph_partuuid.stdout_lines }}" + when: "{{ encrypted_ceph_partuuid.stdout_lines | length > 0 }}" + - name: delete dm-crypt devices if any command: dmsetup remove --retry --force {{ item }} with_items: "{{ encrypted_ceph_partuuid.stdout_lines }}" when: "{{ encrypted_ceph_partuuid.stdout_lines | length > 0 }}" + - name: get payload_offset + shell: cryptsetup luksDump /dev/disk/by-partuuid/{{ item }} | awk '/Payload offset:/ { print $3 }' + register: payload_offset + with_items: "{{ encrypted_ceph_partuuid.stdout_lines }}" + when: "{{ encrypted_ceph_partuuid.stdout_lines | length > 0 }}" + + - name: get physical sector size + command: blockdev --getpbsz /dev/disk/by-partuuid/{{ item }} + with_items: "{{ encrypted_ceph_partuuid.stdout_lines }}" + when: "{{ encrypted_ceph_partuuid.stdout_lines | length > 0 }}" + register: phys_sector_size + + - name: wipe dmcrypt device + command: dd if=/dev/zero of=/dev/disk/by-partuuid/{{ item.0 }} bs={{ item.1.stdout }} count={{ item.2.stdout }} oflag=direct + with_together: + - "{{ encrypted_ceph_partuuid.stdout_lines }}" + - "{{ payload_offset.results }}" + - "{{ phys_sector_size.results }}" + - name: get ceph data partitions shell: | blkid -o device -t PARTLABEL="ceph data"