ansible/roles/networking/templates/debian_interfaces.j2

48 lines
1.4 KiB
Text
Raw Permalink Normal View History

{{ ansible_managed | comment }}
2021-07-05 03:30:57 +02:00
# The loopback network interface
auto lo
iface lo inet loopback
2021-07-10 02:39:21 +02:00
{% for item in lookup('dict', interfaces, wantlist=True) %}
2021-07-11 02:55:12 +02:00
{% if item.value.type not in ['wireguard', 'void', ] %}
auto {{ item.key }}
{% if item.value.type == 'dhcp' %}
iface {{ item.key }} inet dhcp
{% elif item.value.type == 'static' %}
iface {{ item.key }} inet static
2021-07-11 02:55:12 +02:00
{% elif item.value.type == 'manual' %}
iface {{ item.key }} inet manual
{% 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-11 02:55:12 +02:00
{% if 'bridge' in item.value and item.value.bridge %}
{% if 'interfaces' in item.value and item.value.interfaces %}
bridge-ports {{ item.value.interfaces | join(' ') }}
2021-07-11 03:26:20 +02:00
{% else %}
bridge-ports none
2021-07-11 02:55:12 +02:00
{% endif %}
bridge-stp off
bridge-fd 0
{% 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 #}
2021-07-11 02:55:12 +02:00
{% elif item.value.type == 'void' %}{# end (not in [wireguard, void, ]) #}
iface {{ item.key }} inet manual
{% endif %}
{% endfor %}