33 lines
1 KiB
Django/Jinja
33 lines
1 KiB
Django/Jinja
{{ ansible_managed | comment }}
|
|
|
|
# The loopback network interface
|
|
auto lo
|
|
iface lo inet loopback
|
|
|
|
{% for item in lookup('dict', interfaces, wantlist=True) %}
|
|
{% 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 %}
|
|
{% if 'gateway' in item.value %}
|
|
gateway {{ item.value.gateway }}
|
|
{% endif %}
|
|
{% 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 %}
|