2021-07-05 02:32:59 +02:00
|
|
|
{{ ansible_managed | comment }}
|
|
|
|
|
2021-07-05 03:30:57 +02:00
|
|
|
# The loopback network interface
|
|
|
|
auto lo
|
|
|
|
iface lo inet loopback
|
2021-07-08 00:33:13 +02:00
|
|
|
|
|
|
|
{% for item in lookup('dict', interfaces) %}
|
|
|
|
{% if item.value.type not in ['wireguard', ] %}
|
|
|
|
auto {{ item.key }}
|
|
|
|
{% if item.value.type == 'dhcp' %}
|
|
|
|
iface {{ item.key }} inet dhcp
|
|
|
|
{% elif item.value.type == 'static' %}
|
|
|
|
iface {{ item.key }} inet static
|
|
|
|
{% endif %}
|
|
|
|
{% if 'routes' in item.value %}{# route up #}
|
|
|
|
{% for route in item.value.routes %}
|
|
|
|
post-up ip route add {{ route.subnet }}/{{ route.netmask }} via {{ route.gateway }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}{# end route up #}
|
|
|
|
{% if 'ipv4' in item.value %}
|
|
|
|
address {{ item.value.ipv4 }}/{{ item.value.netmaskv4 }}
|
|
|
|
{% endif %}
|
2021-07-08 00:43:58 +02:00
|
|
|
{% if 'gateway' in item.value %}
|
|
|
|
gateway {{ item.value.gateway }}
|
|
|
|
{% endif %}
|
2021-07-08 00:33:13 +02:00
|
|
|
{% if 'routes' in item.value %}{# route dw #}
|
|
|
|
{% for route in item.value.routes %}
|
|
|
|
post-down ip route del {{ route.subnet }}/{{ route.netmask }} via {{ route.gateway }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}{# end route dw #}
|
|
|
|
|
|
|
|
{% endif %}{# end (not in [wireguard, ]) #}
|
|
|
|
{% endfor %}
|