From 73ca1a7a00ae2b8147fb80b7177f54d738439128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 19 Jan 2017 15:28:44 +0100 Subject: [PATCH] purge: remove dm-crypt devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running encrypted OSDs, an encrypted device mapper is used (because created by the crypsetup tool). So before attempting to remove all the partitions on a device we must delete all the encrypted device mappers, then we can delete all the partitions. Signed-off-by: Sébastien Han Please enter the commit message for your changes. Lines starting --- infrastructure-playbooks/purge-cluster.yml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/infrastructure-playbooks/purge-cluster.yml b/infrastructure-playbooks/purge-cluster.yml index fd243b5d3..e09b9552e 100644 --- a/infrastructure-playbooks/purge-cluster.yml +++ b/infrastructure-playbooks/purge-cluster.yml @@ -343,6 +343,35 @@ failed_when: false register: ceph_journal_partlabels +# Initial attempt, doing everything in Ansible... +# - name: see if encrypted partitions are present +# shell: blkid -t TYPE=crypto_LUKS -o value -s PARTUUID +# register: encrypted_partuuid +# +# - name: find if these encrypted partitions are ceph data partitions +# shell: blkid -t PARTLABEL="ceph data" -o value -s PARTUUID $(blkid -U {{ item }}) +# failed_when: false +# with_items: "{{ encrypted_partuuid.stdout_lines }}" +# when: "{{ encrypted_partuuid | length > 0 }}" +# register: encrypted_partuuid_ceph_data +# +# - name: find if these encrypted partitions are ceph journal partitions +# shell: blkid -t PARTLABEL="ceph journal" -o value -s PARTUUID $(blkid -U {{ item }}) +# failed_when: false +# with_items: "{{ encrypted_partuuid.stdout_lines }}" +# when: "{{ encrypted_partuuid | length > 0 }}" +# register: encrypted_partuuid_ceph_journal +# +# - name: merge the list of ceph encrypted partitions +# set_fact: +# encrypted_partuuid_ceph: "{{ encrypted_partuuid_ceph_data + encrypted_partuuid_ceph_journal }}" + + # NOTE(leseb): hope someone will find a more elegant way one day... + - name: see if encrypted partitions are present + shell: | + blkid -t TYPE=crypto_LUKS -s PARTLABEL -s PARTUUID | grep "ceph.*." | grep -o PARTUUID.* | cut -d '"' -f 2 + register: encrypted_ceph_partuuid + - name: get osd data mount points shell: "(grep /var/lib/ceph/osd /proc/mounts || echo -n) | awk '{ print $2 }'" register: mounted_osd @@ -376,6 +405,11 @@ failed_when: false register: ceph_disk_present + - name: delete dm-crypt devices if any + command: dmsetup remove {{ item }} + with_items: encrypted_ceph_partuuid.stdout_lines + when: "{{ encrypted_ceph_partuuid.stdout_lines | length > 0 }}" + - name: zap osd disks shell: ceph-disk zap "{{ item }}" with_items: "{{ devices }}"