feat(network): make interfaces[] canonical, normalize flat fields as AWX compat
This commit is contained in:
@@ -8,6 +8,28 @@
|
||||
{%- set _ = out.update({ 'scsi' ~ loop.index0: hypervisor_cfg.storage ~ ':' ~ (disk.size | int) }) -%}
|
||||
{%- endfor -%}
|
||||
{{ out }}
|
||||
virtualization_proxmox_net: >-
|
||||
{%- set out = {} -%}
|
||||
{%- for iface in system_cfg.network.interfaces -%}
|
||||
{%- set val = 'virtio,bridge=' ~ iface.bridge -%}
|
||||
{%- if iface.vlan | default('') | string | length > 0 -%}
|
||||
{%- set val = val ~ ',tag=' ~ iface.vlan -%}
|
||||
{%- endif -%}
|
||||
{%- set _ = out.update({ 'net' ~ loop.index0: val }) -%}
|
||||
{%- endfor -%}
|
||||
{{ out }}
|
||||
virtualization_proxmox_ipconfig: >-
|
||||
{%- set out = {} -%}
|
||||
{%- for iface in system_cfg.network.interfaces -%}
|
||||
{%- if iface.ip | default('') | string | length > 0 -%}
|
||||
{%- set val = 'ip=' ~ iface.ip ~ '/' ~ iface.prefix
|
||||
~ ((',gw=' ~ iface.gateway) if (iface.gateway | default('') | length > 0) else '') -%}
|
||||
{%- else -%}
|
||||
{%- set val = 'ip=dhcp' -%}
|
||||
{%- endif -%}
|
||||
{%- set _ = out.update({ 'ipconfig' ~ loop.index0: val }) -%}
|
||||
{%- endfor -%}
|
||||
{{ out }}
|
||||
community.proxmox.proxmox_kvm:
|
||||
api_host: "{{ hypervisor_cfg.url }}"
|
||||
api_user: "{{ hypervisor_cfg.username }}"
|
||||
@@ -46,20 +68,8 @@
|
||||
ide0: "{{ boot_iso }},media=cdrom"
|
||||
ide1: "{{ rhel_iso + ',media=cdrom' if rhel_iso is defined and rhel_iso | length > 0 else omit }}"
|
||||
ide2: "{{ hypervisor_cfg.storage }}:cloudinit"
|
||||
net:
|
||||
net0: >-
|
||||
virtio,bridge={{ system_cfg.network.bridge
|
||||
}}{%- if system_cfg.network.vlan is defined
|
||||
and system_cfg.network.vlan | string | length > 0
|
||||
%},tag={{ system_cfg.network.vlan }}{% endif %}
|
||||
ipconfig:
|
||||
ipconfig0: >-
|
||||
{{
|
||||
'ip=' ~ system_cfg.network.ip ~ '/' ~ system_cfg.network.prefix
|
||||
~ (',gw=' ~ system_cfg.network.gateway if system_cfg.network.gateway is defined and system_cfg.network.gateway | length else '')
|
||||
if system_cfg.network.ip is defined and system_cfg.network.ip | string | length
|
||||
else 'ip=dhcp'
|
||||
}}
|
||||
net: "{{ virtualization_proxmox_net }}"
|
||||
ipconfig: "{{ virtualization_proxmox_ipconfig }}"
|
||||
nameservers: "{{ system_cfg.network.dns.servers if system_cfg.network.dns.servers | length else omit }}"
|
||||
searchdomains: "{{ system_cfg.network.dns.search if system_cfg.network.dns.search | length else omit }}"
|
||||
onboot: true
|
||||
|
||||
Reference in New Issue
Block a user