diff options
Diffstat (limited to 'molecule')
| -rw-r--r-- | molecule/default/converge.yml | 45 | ||||
| -rw-r--r-- | molecule/default/molecule.yml | 3 | ||||
| -rw-r--r-- | molecule/default/prepare.yml | 39 |
3 files changed, 39 insertions, 48 deletions
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 11fdd74..ee02902 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -1,4 +1,38 @@ --- +- name: "Discover test devices" + hosts: localhost + gather_facts: false + vars: + distro_key: "{{ lookup('ansible.builtin.env', 'MOLECULE_DISTRO') }}" + scenario_vars: + archlinux: + hostname: "desktop.local" + ubuntu-noble: + hostname: "laptop.local" + ubuntu-resolute: + hostname: "laptop.local" + raspberrypi: + hostname: "rpi5.local" + bootstrap_pi: true + proxmox: + hostname: "pve.local" + bootstrap_proxmox: true + tasks: + - name: "Find loop device for vdd.img" + become: true + ansible.builtin.command: + cmd: "losetup -j /opt/vdd.img" + register: losetup_output + changed_when: false + + - name: "Inject test vars into instance host" + ansible.builtin.add_host: + name: "instance" + test_device: "{{ losetup_output.stdout.split(':')[0] }}" + 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) }}" + - name: Converge hosts: instance gather_facts: true @@ -35,16 +69,9 @@ dev: "{{ partition_disk }}p3" mount_path: "/mnt" partition_extras: [] - bootstrap_pi: "{{ hostvars['localhost']['test_bootstrap_pi'] }}" - bootstrap_proxmox: "{{ hostvars['localhost']['test_bootstrap_proxmox'] }}" + bootstrap_pi: "{{ test_bootstrap_pi }}" + bootstrap_proxmox: "{{ test_bootstrap_proxmox }}" configure_playbook_dir: "../../../ansible-distro-configure" - - pre_tasks: - - name: "Get test facts" - ansible.builtin.set_fact: - test_device: "{{ hostvars['localhost']['test_device'] }}" - test_hostname: "{{ hostvars['localhost']['test_hostname'] }}" - roles: - role: partition - role: bootstrap diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index f749342..07be52c 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -33,9 +33,6 @@ provisioner: ANSIBLE_ROLES_PATH: "../../roles" config_options: defaults: - fact_caching: jsonfile - fact_caching_connection: /tmp/facts_cache - fact_caching_timeout: 600 callback_result_format: yaml interpreter_python: /usr/bin/python3 ssh_connection: diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 6347834..add5d6c 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -1,24 +1,8 @@ --- - name: Prepare hosts: localhost - gather_facts: true + gather_facts: false tasks: - - name: "Set distro test host name mapping" - ansible.builtin.set_fact: - scenario_vars: - archlinux: - hostname: "desktop.local" - ubuntu-noble: - hostname: "laptop.local" - ubuntu-resolute: - 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: @@ -33,23 +17,6 @@ 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" + - name: "Show test device" ansible.builtin.debug: - msg: "{{ item.name }}: {{ item.value }}" - with_items: - - name: "Test Device" - value: "{{ test_device }}" - - name: "Test Hostname;" - value: "{{ test_hostname }}" + msg: "Test device: {{ loop_device.stdout }}" |
