2019-10-05 21:43:05 +00:00
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
|
|
{% if network_interfaces is defined %}
|
|
|
|
network:
|
|
|
|
version: 2
|
|
|
|
ethernets:
|
|
|
|
{% for iface in network_interfaces %}
|
|
|
|
{% if iface.name is defined %}
|
|
|
|
{{ iface.name }}:
|
|
|
|
{% endif %}
|
|
|
|
{% if iface.address is defined %}
|
|
|
|
addresses:
|
|
|
|
{% for addr in iface.address %}
|
|
|
|
- {{ addr }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% if iface.gateway4 is defined %}
|
|
|
|
gateway4: {{ iface.gateway4 }}
|
|
|
|
{% endif %}
|
|
|
|
{% if iface.gateway6 is defined %}
|
|
|
|
gateway6: {{ iface.gateway6 }}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% else %}
|
|
|
|
{# Default network configuration #}
|
|
|
|
network:
|
|
|
|
version: 2
|
|
|
|
ethernets:
|
|
|
|
{% if ansible_default_ipv4.interface is defined %}
|
|
|
|
{{ ansible_default_ipv4.interface }}:
|
|
|
|
{% if ansible_default_ipv4.address is defined or ansible_default_ipv6.address is defined %}
|
|
|
|
addresses:
|
|
|
|
{% if ansible_default_ipv4.address is defined %}
|
2022-08-31 03:30:13 +00:00
|
|
|
- {{ ansible_default_ipv4.address }}/{{ (ansible_default_ipv4.network + "/" + ansible_default_ipv4.netmask) | ansible.utils.ipaddr('prefix') }}
|
2019-10-05 21:43:05 +00:00
|
|
|
{% endif %}
|
|
|
|
{% if ansible_default_ipv6.address is defined %}
|
|
|
|
- {{ ansible_default_ipv6.address }}/{{ ansible_default_ipv6.prefix }}
|
|
|
|
{% endif %}
|
|
|
|
{% if ansible_default_ipv4.gateway is defined %}
|
|
|
|
gateway4: {{ ansible_default_ipv4.gateway }}
|
|
|
|
{% endif %}
|
|
|
|
{% if ansible_default_ipv6.gateway is defined %}
|
|
|
|
gateway6: {{ ansible_default_ipv6.gateway }}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|