2023-12-18 10:22:14 +00:00
|
|
|
{# Note that there must be exactly one VLAN-aware bridge. #}
|
|
|
|
{% set bridge = interfaces | selectattr('type') | selectattr('type.value', '==', 'bridge') | first %}
|
2023-12-11 19:31:44 +00:00
|
|
|
{# interfaces that belong to this bridge #}
|
|
|
|
{% set ports = interfaces | selectattr('enabled') | selectattr('bridge') | selectattr('bridge.name', '==', bridge.name) %}
|
|
|
|
{# allowed VLANs can be specified on the bridge, any of its ports, or all VLANs in NetBox #}
|
2023-12-29 12:51:38 +00:00
|
|
|
{% set my_vlans = bridge.tagged_vlans or (ports | iface_vlans | flatten | sort(attribute='vid') | unique) or vlans %}
|
2023-12-18 10:22:14 +00:00
|
|
|
{% set my_vlan_ids = my_vlans | map(attribute='vid') | sort -%}
|
|
|
|
|
|
|
|
auto {{ bridge.name }}
|
|
|
|
iface {{ bridge.name }}
|
|
|
|
bridge-ports {{ ports | map(attribute='name') | join(' ') }}{% if my_vlans %} vxlan{% endif +%}
|
|
|
|
bridge-vlan-aware yes
|
|
|
|
bridge-pvid 1
|
|
|
|
{% if bridge.mode.value == 'tagged' and my_vlans %}
|
|
|
|
bridge-vids {{ my_vlan_ids | join(' ') }}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if my_vlans %}
|
|
|
|
auto vxlan
|
|
|
|
iface vxlan
|
|
|
|
bridge-vlan-vni-map {{ my_vlan_ids | zip(my_vlan_ids) | map('join', '=') | join(' ') }}
|
|
|
|
bridge-learning off
|
|
|
|
{% endif %}
|