feat(network): make interfaces[] canonical, normalize flat fields as AWX compat
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
network:
|
||||
version: 2
|
||||
ethernets:
|
||||
id0:
|
||||
match:
|
||||
macaddress: "{{ virtualization_mac_address }}"
|
||||
{% set has_static = system_cfg.network.ip is defined and system_cfg.network.ip | string | length %}
|
||||
{% set dns_list = system_cfg.network.dns.servers | default([]) %}
|
||||
{% set search_list = system_cfg.network.dns.search | default([]) %}
|
||||
{% for iface in system_cfg.network.interfaces %}
|
||||
{% set iface_mac = '52:54:00' | community.general.random_mac(seed=hostname if loop.index0 == 0 else hostname ~ '-nic' ~ loop.index0) %}
|
||||
{% set has_static = (iface.ip | default('') | string | length) > 0 %}
|
||||
id{{ loop.index0 }}:
|
||||
match:
|
||||
macaddress: "{{ iface_mac }}"
|
||||
{% if has_static %}
|
||||
addresses:
|
||||
- "{{ system_cfg.network.ip }}/{{ system_cfg.network.prefix }}"
|
||||
{% if system_cfg.network.gateway is defined and system_cfg.network.gateway | string | length %}
|
||||
gateway4: "{{ system_cfg.network.gateway }}"
|
||||
- "{{ iface.ip }}/{{ iface.prefix }}"
|
||||
{% if iface.gateway | default('') | string | length %}
|
||||
gateway4: "{{ iface.gateway }}"
|
||||
{% endif %}
|
||||
{% else %}
|
||||
dhcp4: true
|
||||
{% if dns_list | length or search_list | length %}
|
||||
{% if loop.index0 == 0 and (dns_list | length or search_list | length) %}
|
||||
dhcp4-overrides:
|
||||
{% if dns_list | length %}
|
||||
use-dns: false
|
||||
@@ -25,7 +27,7 @@ network:
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if dns_list or search_list %}
|
||||
{% if loop.index0 == 0 and (dns_list or search_list) %}
|
||||
nameservers:
|
||||
{% if dns_list %}
|
||||
addresses:
|
||||
@@ -40,3 +42,4 @@ network:
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user