2018-06-21 08:24:28 +00:00
|
|
|
- name: 'Create a "disk" file'
|
|
|
|
command: 'dd if=/dev/zero of={{ image_file }} bs=1M count={{ fssize }}'
|
|
|
|
|
|
|
|
- vars:
|
|
|
|
dev: '{{ image_file }}'
|
|
|
|
block:
|
|
|
|
- when: fstype == 'lvm'
|
|
|
|
block:
|
|
|
|
- name: 'Create a loop device for LVM'
|
|
|
|
command: 'losetup --show -f {{ dev }}'
|
|
|
|
register: loop_device_cmd
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
dev: "{{ loop_device_cmd.stdout }}"
|
|
|
|
|
|
|
|
- include_tasks: '{{ action }}.yml'
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: 'Detach loop device used for LVM'
|
|
|
|
command: 'losetup -d {{ dev }}'
|
|
|
|
args:
|
|
|
|
removes: '{{ dev }}'
|
|
|
|
when: fstype == 'lvm'
|
|
|
|
|
2018-07-09 18:56:43 +00:00
|
|
|
- name: 'Clean correct device for LVM'
|
|
|
|
set_fact:
|
|
|
|
dev: '{{ image_file }}'
|
|
|
|
when: fstype == 'lvm'
|
|
|
|
|
2018-06-21 08:24:28 +00:00
|
|
|
- file:
|
|
|
|
name: '{{ image_file }}'
|
|
|
|
state: absent
|