From a132f2af1e2ccf93dd6478672fa008d3fd298e32 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 5 Mar 2023 17:11:40 +0100 Subject: elevate/dione: add vlan interface for lan --- dan/ele-dione.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'dan/ele-dione.yml') diff --git a/dan/ele-dione.yml b/dan/ele-dione.yml index eab42550..c486fc08 100644 --- a/dan/ele-dione.yml +++ b/dan/ele-dione.yml @@ -45,3 +45,32 @@ {{ module }} {% endfor %} dest: /etc/modules-load.d/sensors.conf + + ## TODO: move to network/interfaces when this is done + - name: install vlan interfaces + loop: "{{ network.vlans | dict2items }}" + loop_control: + label: "{{ item.key }} ({{ item.value | join(',') }})" + copy: + dest: "/etc/network/interfaces.d/{{ item.key }}" + content: | + auto {{ item.key }} + iface {{ item.key }} inet manual + {% for vlan in item.value %} + {% set vlan_ifname = item.key + '.' + (vlan | string) %} + {% set vlan_iface = (network.interfaces | selectattr('name', 'eq', vlan_ifname)) %} + + auto {{ vlan_ifname }} + {% if vlan_iface %} + iface {{ vlan_ifname }} inet static + address {{ (vlan_iface | first).address }} + {% for route in vlan_iface[0].static_routes | default([]) %} + up /bin/ip route add {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %}{{ '' }} + {% endfor %} + {% for route in vlan_iface[0].static_routes | default([]) | reverse %} + down /bin/ip route del {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %}{{ '' }} + {% endfor %} + {% else %} + iface {{ vlan_ifname }} inet manual + {% endif %} + {% endfor %} -- cgit v1.2.3