]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
purge: remove dm-crypt devices 1235/head
authorSébastien Han <seb@redhat.com>
Thu, 19 Jan 2017 14:28:44 +0000 (15:28 +0100)
committerSébastien Han <seb@redhat.com>
Wed, 25 Jan 2017 21:32:46 +0000 (22:32 +0100)
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 <seb@redhat.com>
 Please enter the commit message for your changes. Lines starting

infrastructure-playbooks/purge-cluster.yml

index fd243b5d38cd840b3627db70c57289241b27996f..e09b9552eaeb709fb9536bcbfefc63030b31b420 100644 (file)
     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
     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 }}"