]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
purge_cluster: fix dmcrypt purge
authorGuillaume Abrioux <gabrioux@redhat.com>
Fri, 18 May 2018 15:56:03 +0000 (17:56 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 21 May 2018 06:23:10 +0000 (08:23 +0200)
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 <gabrioux@redhat.com>
infrastructure-playbooks/purge-cluster.yml

index bcba8b05addcebca367ff2da6509e335b0559065..df741c8424045ba29297832efbf3fdd94c8b1e20 100644 (file)
     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"