summaryrefslogtreecommitdiff
path: root/test/integration/targets/filesystem/tasks/create_device.yml
blob: 052934cc541320d8a224b3b3c5ddd68106fd51d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
- 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'

    - name: 'Clean correct device for LVM'
      set_fact:
        dev: '{{ image_file }}'
      when: fstype == 'lvm'

    - file:
        name: '{{ image_file }}'
        state: absent