summaryrefslogtreecommitdiff
path: root/roles/vm/host/network/templates/interfaces.j2
diff options
context:
space:
mode:
Diffstat (limited to 'roles/vm/host/network/templates/interfaces.j2')
-rw-r--r--roles/vm/host/network/templates/interfaces.j243
1 files changed, 17 insertions, 26 deletions
diff --git a/roles/vm/host/network/templates/interfaces.j2 b/roles/vm/host/network/templates/interfaces.j2
index 004c1f96..6daa22bd 100644
--- a/roles/vm/host/network/templates/interfaces.j2
+++ b/roles/vm/host/network/templates/interfaces.j2
@@ -22,39 +22,20 @@ iface {{ interface }} inet manual
{% set tmp = network.interfaces | selectattr('name', 'eq', bond.name) | list %}
auto {{ bond.name }}
iface {{ bond.name }} inet {{ ((tmp | length) == 0) | ternary('manual', 'static') }}
+ up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
+ up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
bond-mode {{ bond.mode }}
bond-slaves {{ bond.slaves | sort | join(' ') }}
{% for option in (bond.options | default({}) | list | sort) %}
bond-{{ option }} {{ bond.options[option] }}
{% endfor %}
- up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
- up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
{% if (tmp | length) > 0 %}
{% set interface = tmp | first %}
- address {{ interface.address | ipaddr('address') }}
- netmask {{ interface.address | ipaddr('netmask') }}
-{% if 'gateway' in interface %}
- gateway {{ interface.gateway }}
-{% endif %}
-{% for route in interface.static_routes | default([]) %}
- up /bin/ip route add {{ route.destination }} via {{ route.gateway }}
-{% endfor %}
-{% for route in interface.static_routes | default([]) | reverse %}
- down /bin/ip route del {{ route.destination }} via {{ route.gateway }}
-{% endfor %}
+{% include 'interfaces/' + (interface.config | default('simple')) + '.j2' %}
{% if 'address6' in interface %}
iface {{ interface.name }} inet6 static
- address {{ interface.address6 }}
-{% if 'gateway6' in interface %}
- gateway {{ interface.gateway6 }}
-{% endif %}
-{% for route in interface.static_routes6 | default([]) %}
- up /bin/ip -6 route add {{ route.destination }} via {{ route.gateway }}
-{% endfor %}
-{% for route in interface.static_routes6 | default([]) | reverse %}
- down /bin/ip -6 route del {{ route.destination }} via {{ route.gateway }}
-{% endfor %}
+{% include 'interfaces/' + (interface.config | default('simple6')) + '.j2' %}
{% endif %}
{% endif %}
@@ -64,11 +45,21 @@ iface {{ interface.name }} inet6 static
## vlan interfaces @ {{ parent }}
{% for vlan in network.vlans[parent] %}
-auto {{ parent }}.{{ vlan }}
-iface {{ parent }}.{{ vlan }} inet manual
+{% set interface_name = parent+'.'+(vlan | string) %}
+{% set tmp = network.interfaces | selectattr('name', 'eq', interface_name) | list %}
+auto {{ interface_name }}
+iface {{ interface_name }} inet {{ ((tmp | length) == 0) | ternary('manual', 'static') }}
up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
-{# TODO: add interface config like above if (network.interfaces | selectattr('name', 'eq', 'parent+'.'+vlan') | list) > 0 ... #}
+{% if (tmp | length) > 0 %}
+{% set interface = tmp | first %}
+{% include 'interfaces/' + (interface.config | default('simple')) + '.j2' %}
+{% if 'address6' in interface %}
+
+iface {{ interface.name }} inet6 static
+{% include 'interfaces/' + (interface.config | default('simple6')) + '.j2' %}
+{% endif %}
+{% endif %}
{% endfor %}