commit 28b30cc6608cb80678904ede5a26bdae63dcdafb
parent e3714471485801407fe4ff8cd55fb194ad1b82bf
Author: Leah Thein <leah@toaster.fritz.box>
Date: Thu, 3 Dec 2020 00:12:09 +0100
parent e3714471485801407fe4ff8cd55fb194ad1b82bf
Author: Leah Thein <leah@toaster.fritz.box>
Date: Thu, 3 Dec 2020 00:12:09 +0100
common: dynamic configuration of interfaces
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/roles/common/templates/awall-baseconfig.json.j2 b/roles/common/templates/awall-baseconfig.json.j2 @@ -1,9 +1,9 @@ { - "description": "Base zones and policies for wanderduene", + "description": "Base zones and policies for {{network.hostname}}", "import": [ "custom-services" ], "zone": { - "WAN": { "iface": "{{ network.interface }}" } + "WAN": { "iface": "{{ network.awall.wan }}" } }, "policy": [
diff --git a/roles/common/templates/interfaces.conf.j2 b/roles/common/templates/interfaces.conf.j2 @@ -1,16 +1,30 @@ -auto lo -iface lo inet loopback - -auto {{ network.interface }} -iface {{ network.interface }} inet static +{% for interface in network.interfaces %} +auto {{ interface.name }} +{% if interface.loopback is defined %} +iface {{ interface.name }} inet loopback +{% else %} +{% if interface.ipv4.dhcp is defined %} +iface {{ interface.name }} inet dhcp +{% else %} +iface {{ interface.name }} inet static hostname {{ network.hostname }} - address {{ network.ipv4.address }} - netmask {{ network.ipv4.netmask }} - gateway {{ network.ipv4.gateway }} + address {{ interface.ipv4.address }} + netmask {{ interface.ipv4.netmask }} + gateway {{ interface.ipv4.gateway }} +{% endif%} -auto {{ network.interface }} -iface {{ network.interface }} inet6 static +{% if interface.ipv6 is defined %} +auto {{ interface.name }} +{% if interface.ipv6.stateless %} +iface {{ interface.name }} inet6 auto +{% else %} +iface {{ interface.name }} inet6 static hostname {{ network.hostname }} - address {{ network.ipv6.address }} - netmask {{ network.ipv6.netmask }} - gateway {{ network.ipv6.gateway }} + address {{ interface.ipv6.address }} + netmask {{ interface.ipv6.netmask }} + gateway {{ interface.ipv6.gateway }} +{% endif %} +{% endif %} +{% endif %} + +{% endfor %}+ \ No newline at end of file