summaryrefslogtreecommitdiffstats
path: root/molecule/default/prepare.yml
blob: e62ccab0d446adac766906082a226256e34d4cd2 (plain) (blame)
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
33
34
35
36
37
38
---
- name: Prepare
  hosts: localhost
  gather_facts: true
  tasks:
    - name: "Set distro test host name mapping"
      ansible.builtin.set_fact:
        distro_hostname_mapping:
          archlinux: "archlinux.local"

    - name: "Create virtual disk image"
      become: true
      community.general.filesize:
        path: "/opt/vdd.img"
        size: 12G
        mode: "0755"

    - name: "Create test_device (loop block device)"
      become: true
      ansible.builtin.command:
        cmd: "losetup --show -Pf /opt/vdd.img"
      register: loop_device
      changed_when: true

    - name: "Set test facts"
      ansible.builtin.set_fact:
        test_device: "{{ loop_device.stdout }}"
        test_hostname: "{{ distro_hostname_mapping[lookup('ansible.builtin.env', 'MOLECULE_DISTRO')] }}"
        cacheable: true

    - name: "Show test info"
      ansible.builtin.debug:
        msg: "{{ item.name }}: {{ item.value }}"
      with_items:
        - name: "Test Device"
          value: "{{ test_device }}"
        - name: "Test Hostname;"
          value: "{{ test_hostname }}"