]> 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)
committerSébastien Han <seb@redhat.com>
Tue, 22 May 2018 14:43:48 +0000 (16:43 +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>
(cherry picked from commit 9801bde4d4ce501208fc297d5cb0ab2e0aa28702)

infrastructure-playbooks/purge-cluster.yml

index 5ea74d4586f6d8e214faef0697e5d543128f0a47..bb9a8a3cd0214fccaaedf70669657da1a55c30ba 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"