Ensure loop devices created by DLRN get's cleaned up

DLRN with mock-2.2 creates /dev/loop[0-11] devices,
in CI we rely on /dev/loop devices for setting up block
devices, so let's ensure the loop devices get's cleaned up.

Related-Bug: #1872881
Change-Id: I5295fbb45b79a3e2edea2b24fa007fc011549d77
This commit is contained in:
yatinkarel 2020-04-20 17:33:40 +05:30
parent cb6c9c47c8
commit c57822580d
1 changed files with 16 additions and 0 deletions

View File

@ -219,6 +219,16 @@
debug:
var: artg_change_list
- name: Check loop devices stat
stat:
path: "/dev/loop{{ item }}"
register: stat_loop_devices
with_sequence: start=0 end=11
- name: Set loop_devices_absent fact
set_fact:
loop_devices_absent: "{{ stat_loop_devices.results|selectattr('stat.exists','equalto',false)|map(attribute='item')|list }}"
- name: Clone and build the specific DLRN projects
include: dlrn-build.yml artg_change={{ item }}
with_items: '{{ artg_change_list|default([]) }}'
@ -251,6 +261,12 @@
register: repo_built_multi
when: not artg_build_one|bool
- name: Clean up loop devices created by mock
file:
path: "/dev/loop{{ item }}"
state: absent
become: true
with_items: "{{ loop_devices_absent }}"
- block:
- name: Create a directory to hold the rpms