diff --git a/playbooks/cleanup_cinder_volumes.yml b/playbooks/cleanup_cinder_volumes.yml index f7842aa..92bc735 100644 --- a/playbooks/cleanup_cinder_volumes.yml +++ b/playbooks/cleanup_cinder_volumes.yml @@ -13,13 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: "Detach any loop devices in use" - sudo: yes - shell: for loopdevice in `losetup -a| cut -d ':' -f 1`; do losetup --detach $loopdevice; done - name: "Remove any cinder volume mounts that may be present" sudo: yes - shell: for CINDER_VOLUME in `dmsetup ls 2>/dev/null | cut -f 1 |grep 'cinder--volumes'`; do dmsetup remove $CINDER_VOLUME; done + script: files/cleanup_cinder_devices.sh + register: test_cinder_cleanup ignore_errors: yes - register: test_cinder_volume_remove +- name: "If cinder cleanup failed, collect volume group data" + command: vgdisplay -v + when: instance_status == "ACTIVE" and test_cinder_cleanup.rc != 0 - include: step_fail_unmount.yml - when: instance_status == "ACTIVE" and test_cinder_volume_remove.rc != 0 + when: instance_status == "ACTIVE" and test_cinder_cleanup.rc != 0 +- name: "Detach any loop devices in use" + sudo: yes + script: files/cleanup_loop_devices.sh + register: test_loop_device_cleanup +- name: "Collect list of loop devices" + sudo: yes + command: losetup -a + ignore_errors: yes + when: test_loop_device_cleanup.rc != 0 +- include: step_fail_unmount.yml + when: instance_status == "ACTIVE" and test_loop_device_cleanup.rc != 0 diff --git a/playbooks/files/cleanup_cinder_devices.sh b/playbooks/files/cleanup_cinder_devices.sh new file mode 100644 index 0000000..35842f5 --- /dev/null +++ b/playbooks/files/cleanup_cinder_devices.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -eux + +for CINDER_VOLUME in `dmsetup ls 2>/dev/null | cut -f 1 |grep 'cinder--volumes'|grep -v pool`; do + dmsetup remove $CINDER_VOLUME +done +vgchange -a n diff --git a/playbooks/files/cleanup_loop_devices.sh b/playbooks/files/cleanup_loop_devices.sh new file mode 100644 index 0000000..e8913fe --- /dev/null +++ b/playbooks/files/cleanup_loop_devices.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -eux + +for loopdevice in `losetup -a| cut -d ':' -f 1`; do + losetup --detach $loopdevice +done