|
89 | 89 | vm_name: "{{ hostvars['bastion'].vm_name }}"
|
90 | 90 | vm_disk_name: "{{ vm_name }}_main.qcow2"
|
91 | 91 | libvirtd_disk_path: /var/lib/libvirt/images
|
92 |
| - vm_net_config: |
93 |
| - network: |
94 |
| - version: 2 |
95 |
| - ethernets: |
96 |
| - "{{ hostvars['bastion'].vm_external_interface }}": |
97 |
| - match: |
98 |
| - name: "{{ hostvars['bastion'].vm_external_interface }}" |
99 |
| - addresses: |
100 |
| - - "{{ hostvars['bastion'].ansible_host }}/{{ hostvars['bastion'].net_prefix }}" |
101 |
| - gateway4: "{{ hostvars['bastion'].gateway }}" |
102 |
| - nameservers: |
103 |
| - addresses: ["{{ hostvars['bastion'].dns }}"] |
104 | 92 | tasks:
|
105 | 93 |
|
| 94 | + - name: Render network configuration |
| 95 | + ansible.builtin.set_fact: |
| 96 | + vm_net_config: |
| 97 | + network: |
| 98 | + version: 2 |
| 99 | + ethernets: |
| 100 | + external-connection: |
| 101 | + match: |
| 102 | + name: "{{ hostvars['bastion'].vm_external_interface }}" |
| 103 | + addresses: |
| 104 | + - "{{ hostvars['bastion'].ansible_host }}/{{ hostvars['bastion'].net_prefix }}" |
| 105 | + gateway4: "{{ hostvars['bastion'].gateway }}" |
| 106 | + gateway6: "{{ hostvars['bastion'].gateway6 | default(omit) }}" |
| 107 | + dhcp4: false |
| 108 | + nameservers: |
| 109 | + addresses: ["{{ hostvars['bastion'].dns }}"] |
| 110 | + |
| 111 | + - name: Append IPv6 to vm_net_config |
| 112 | + when: hostvars['bastion'].ipv6 is defined |
| 113 | + ansible.builtin.set_fact: |
| 114 | + vm_net_config: >- |
| 115 | + {{ |
| 116 | + vm_net_config | combine( |
| 117 | + { |
| 118 | + 'network': { |
| 119 | + 'ethernets': { |
| 120 | + 'external-connection': { |
| 121 | + 'addresses': (vm_net_config.network.ethernets['external-connection'].addresses + [hostvars['bastion'].ipv6]) |
| 122 | + } |
| 123 | + } |
| 124 | + } |
| 125 | + }, |
| 126 | + recursive=True |
| 127 | + ) |
| 128 | + }} |
| 129 | +
|
106 | 130 | - name: Gather VM qcow image
|
107 | 131 | ansible.builtin.get_url:
|
108 | 132 | url: "{{ vm_qcow_url }}"
|
|
240 | 264 | name: "{{ hostname }}"
|
241 | 265 | become: true
|
242 | 266 |
|
| 267 | + - name: Rename external connection |
| 268 | + become: true |
| 269 | + ansible.builtin.command: nmcli connection modify "System external-connection" connection.id external |
| 270 | + changed_when: false |
| 271 | + |
243 | 272 | - name: Ensure epel repo present
|
244 | 273 | ansible.builtin.dnf:
|
245 | 274 | name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm"
|
|
255 | 284 | - firewalld
|
256 | 285 | - podman
|
257 | 286 | - tmux
|
| 287 | + - java |
258 | 288 | state: present
|
259 | 289 | become: true
|
0 commit comments