summaryrefslogtreecommitdiff
path: root/roles/vm/host/network/templates/bridge-interfaces.j2
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-07-22 23:42:03 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-07-22 23:42:03 +0200
commit8c76a1b0c6e925b529b1cd03ded5b9d0b3d707c4 (patch)
treee3b4ead7fa5fd34f0f64c6b5fe8ebc944ca7bdc0 /roles/vm/host/network/templates/bridge-interfaces.j2
parentadd some more interface configs (diff)
yet another refactoring of the network config
Diffstat (limited to 'roles/vm/host/network/templates/bridge-interfaces.j2')
-rw-r--r--roles/vm/host/network/templates/bridge-interfaces.j230
1 files changed, 16 insertions, 14 deletions
diff --git a/roles/vm/host/network/templates/bridge-interfaces.j2 b/roles/vm/host/network/templates/bridge-interfaces.j2
index 4d80db4c..426f91f8 100644
--- a/roles/vm/host/network/templates/bridge-interfaces.j2
+++ b/roles/vm/host/network/templates/bridge-interfaces.j2
@@ -1,8 +1,8 @@
{% set bridge_name = 'br-'+item.key %}
{% set bridge = item.value %}
-{% set interface = (network.interfaces | selectattr('name', 'eq', bridge_name) | first | default({})) %}
+{% set matched = (network.interfaces | selectattr('name', 'eq', bridge_name) | list) %}
auto {{ bridge_name }}
-iface {{ bridge_name }} inet {{ ('address' in interface) | ternary('static', 'manual') }}
+iface {{ bridge_name }} inet {{ ((matched | 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
bridge_ports {{ bridge.interfaces | default(['none']) | join(' ') }}
@@ -13,11 +13,12 @@ iface {{ bridge_name }} inet {{ ('address' in interface) | ternary('static', 'ma
up /sbin/sysctl net.bridge.bridge-nf-call-iptables=0
up /sbin/sysctl net.bridge.bridge-nf-call-ip6tables=0
up /sbin/sysctl net.bridge.bridge-nf-call-arptables=0
-{% if 'address' in interface %}
- address {{ interface.address | ipaddr('address') }}
- netmask {{ interface.address | ipaddr('netmask') }}
-{% if 'gateway' in interface %}
- gateway {{ interface.gateway }}
+{% if (matched | length) > 0 %}
+{% set interface = matched | first %}
+{% if 'content' in interface %}
+ {{ interface.content | indent(2) }}
+{% else %}
+{% include 'interfaces/' + (interface.template | default('simple')) + '.j2' %}
{% endif %}
{% if 'prefix' in bridge %}
{% if 'nat' in bridge and bridge.nat %}
@@ -26,7 +27,7 @@ iface {{ bridge_name }} inet {{ ('address' in interface) | ternary('static', 'ma
up /sbin/iptables -t nat -A POSTROUTING -o {{ ansible_default_ipv4.interface }} -s {{ bridge.prefix }} -j SNAT --to {{ ansible_default_ipv4.address }}
{% endif %}
{% for overlay_name in (bridge.overlays | default({}) | list | sort) %}
-{% set overlay = bridge.overlays[overlay_name] %}
+{% set overlay = bridge.overlays[overlay_name] %}
{% for dest, offset in (overlay.offsets | dictsort(by='value')) %}
up /bin/ip route add {{ (overlay.prefix | ipaddr(offset)).split('/')[0] }}/32 via {{ (bridge.prefix | ipaddr(bridge.offsets[dest])).split('/')[0] }} # {{ dest }}
{% endfor %}
@@ -37,12 +38,13 @@ iface {{ bridge_name }} inet {{ ('address' in interface) | ternary('static', 'ma
down /sbin/iptables -t nat -D POSTROUTING -o {{ ansible_default_ipv4.interface }} -s {{ bridge.prefix }} -j SNAT --to {{ ansible_default_ipv4.address }}
{% endif %}
{% endif %}
-{% endif %}
-{% if 'address6' in interface %}
+{% if 'content6' in interface or 'address6' in interface %}
-iface {{ bridge_name }} inet6 static
- address {{ interface.address6 }}
-{% if 'gateway6' in interface %}
- gateway {{ interface.gateway6 }}
+iface {{ interface.name }} inet6 static
+{% if 'content6' in interface %}
+ {{ interface.content6 | indent(2) }}
+{% else %}
+{% include 'interfaces/' + (interface.template6 | default('simple6')) + '.j2' %}
+{% endif %}
{% endif %}
{% endif %}