30 lines
967 B
Django/Jinja
30 lines
967 B
Django/Jinja
{{ ansible_managed | comment }}
|
|
|
|
auto {{ item.key }}
|
|
{% if item.value.type == 'wireguard' %}
|
|
iface {{ item.key }} inet static
|
|
{% elif item.value.type == 'dhcp' %}
|
|
iface {{ item.key }} inet dhcp
|
|
{% elif item.value.type == 'static' %}
|
|
iface {{ item.key }} inet static
|
|
{% endif %}
|
|
{% if item.value.type == 'wireguard' %}
|
|
pre-up ip link add $IFACE type wireguard
|
|
pre-up wg setconf $IFACE /etc/wireguard/$IFACE.conf
|
|
{% endif %}
|
|
{% if 'routes' in item.value %}
|
|
{% for route in item.value.routes %}
|
|
post-up ip route add {{ route.subnet }}/{{ route.netmask }} via {{ route.gateway }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if 'ipv4' in item.value %}
|
|
address {{ item.value.ipv4 }}/{{ item.value.netmaskv4 }}
|
|
{% endif %}
|
|
{% if 'routes' in item.value %}
|
|
{% for route in item.value.routes %}
|
|
post-down ip route del {{ route.subnet }}/{{ route.netmask }} via {{ route.gateway }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if item.value.type == 'wireguard' %}
|
|
post-down ip link del $IFACE
|
|
{% endif %}
|