Skip to content

Commit

Permalink
restructured creation of instances ipv4 and ports dicts, added vmnet-…
Browse files Browse the repository at this point in the history
…shared ports dict setup
  • Loading branch information
andreygubarev committed Feb 21, 2024
1 parent b771f48 commit 2fae220
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions molecule_qemu/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,19 +364,22 @@
ansible.builtin.set_fact:
molecule_instances_ipv4: {}

- name: Create instances IPv4 dict
- name: Create instances ports empty dict
ansible.builtin.set_fact:
molecule_instances_ipv4: "{{ molecule_instances_ipv4 | combine({item.name: '127.0.0.1'}) }}"
loop: "{{ molecule_instances }}"
loop_control:
label: "{{ item.name }}"
molecule_instances_ports: {}

### qemu network: user ####################################################

- name: Configure QEMU network (user)
when: qemu_network_mode == 'user'
block:
- name: Get forwarded ports
- name: Create instances IPv4 dict (user)
ansible.builtin.set_fact:
molecule_instances_ipv4: "{{ molecule_instances_ipv4 | combine({item.name: '127.0.0.1'}) }}"
loop: "{{ molecule_instances }}"
loop_control:
label: "{{ item.name }}"

- name: Get forwarded ports (user)
become: "{{ qemu_privileged }}"
ansible.builtin.shell: |
set -o pipefail
Expand All @@ -386,11 +389,7 @@
label: "{{ item.name }}"
register: molecule_instances_ports_output

- name: Create instances ports empty dict
ansible.builtin.set_fact:
molecule_instances_ports: {}

- name: Create instances ports dict
- name: Create instances ports dict (user)
ansible.builtin.set_fact:
molecule_instances_ports: "{{ molecule_instances_ports | combine({item.item.name: item.stdout}) }}"
loop: "{{ molecule_instances_ports_output.results }}"
Expand Down Expand Up @@ -422,6 +421,13 @@
loop_control:
label: "{{ item.item.name }}"

- name: Create instances ports dict (vmnet-shared)
ansible.builtin.set_fact:
molecule_instances_ports: "{{ molecule_instances_ports | combine({item.name: '22'}) }}"
loop: "{{ molecule_instances }}"
loop_control:
label: "{{ item.name }}"

### ssh ###################################################################

- name: Wait for SSH
Expand Down

0 comments on commit 2fae220

Please sign in to comment.