summaryrefslogtreecommitdiffstats
path: root/molecule/default/prepare.yml
blob: 76b7787e680cacea59c5665e265aa489df06bf3a (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
- name: Prepare
  hosts: localhost
  gather_facts: true
  tasks:
    - name: "Set distro test host name mapping"
      ansible.builtin.set_fact:
        scenario_vars:
          archlinux:
            hostname: "desktop.local"
          ubuntu:
            hostname: "laptop.local"
          raspberrypi:
            hostname: "rpi5.local"
            bootstrap_pi: true
          proxmox:
            hostname: "pve.local"
            bootstrap_proxmox: true

    - 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 distro key"
      ansible.builtin.set_fact:
        distro_key: "{{ lookup('ansible.builtin.env', 'MOLECULE_DISTRO') }}"

    - name: "Set test facts"
      ansible.builtin.set_fact:
        test_device: "{{ loop_device.stdout }}"
        test_hostname: "{{ scenario_vars[distro_key].hostname }}"
        test_bootstrap_pi: "{{ scenario_vars[distro_key].bootstrap_pi | default(false) }}"
        test_bootstrap_proxmox: "{{ scenario_vars[distro_key].bootstrap_proxmox | default(false) }}"
        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 }}"