]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
testnode: Be super aggressive with wiping LVM data 345/head
authorDavid Galloway <dgallowa@redhat.com>
Tue, 31 Oct 2017 19:02:33 +0000 (15:02 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Tue, 31 Oct 2017 19:06:24 +0000 (15:06 -0400)
Fixes: http://tracker.ceph.com/issues/21989
Fixes: http://tracker.ceph.com/issues/21935 (hopefully)
Signed-off-by: David Galloway <dgallowa@redhat.com>
roles/testnode/tasks/zap_disks.yml

index ad6ef74370252fe7e4a2757dfd6b3f646688d612..7ef967e2c54bf44c6586ce075ca0a49d53be8ede 100644 (file)
 
 - name: Remove all LVM data
   shell: "dmsetup remove_all --force"
+  register: removed_lvm_data
+  until: "'Unable to remove' not in removed_lvm_data.stderr"
+  retries: 5
+  delay: 1
+  ignore_errors: true
+
+## See http://tracker.ceph.com/issues/21989
+## Following 6 tasks only get run if `dmsetup remove_all` fails
+- name: Check for logical volumes
+  shell: "lvdisplay | grep 'LV Path' | awk '{ print $3 }'"
+  register: lvs_to_remove
+  when: removed_lvm_data|failed
+
+- name: Check for volume groups
+  shell: "vgdisplay | grep 'VG Name' | awk '{ print $3 }'"
+  register: vgs_to_remove
+  when: removed_lvm_data|failed
+
+- name: Check for physical volumes
+  shell: "pvdisplay | grep 'PV Name' | awk '{ print $3 }'"
+  register: pvs_to_remove
+  when: removed_lvm_data|failed
+
+# The lvol ansible module is not used here because the vg name is required and that'd get messy
+- name: Remove logical volumes
+  shell: "lvremove --force {{ item }}"
+  with_items: "{{ lvs_to_remove.stdout_lines }}"
+  when:
+    - removed_lvm_data|failed
+    - lvs_to_remove is defined
+    - lvs_to_remove.stdout_lines|length > 0
+
+- name: Remove volume groups
+  lvg:
+    vg: "{{ item }}"
+    state: absent
+    force: yes
+  with_items: "{{ vgs_to_remove.stdout_lines }}"
+  when:
+    - removed_lvm_data|failed
+    - vgs_to_remove is defined
+    - vgs_to_remove.stdout_lines|length > 0
+
+- name: Remove physical volumes
+  shell: "pvremove --force {{ item }}"
+  with_items: "{{ pvs_to_remove.stdout_lines }}"
+  when:
+    - removed_lvm_data|failed
+    - pvs_to_remove is defined
+    - pvs_to_remove.stdout_lines|length > 0