diff --git a/roles/proxmox/templates/interfaces.j2 b/roles/proxmox/templates/interfaces.j2 index d21f582..e8649bc 100644 --- a/roles/proxmox/templates/interfaces.j2 +++ b/roles/proxmox/templates/interfaces.j2 @@ -1,30 +1,22 @@ -{# Keep vmbr0 named as is and in the main interfaces file so Proxmox can find it. #} -{% set bridge = interfaces | selectattr('type') | selectattr('type.value', '==', 'bridge') | first %} -{% set my_vlan_ids = bridge.tagged_vlans | default([]) | map(attribute='vid') | sort -%} +{% set my_cluster = query('netbox.netbox.nb_lookup', 'clusters', raw_data=true, + api_filter='name='~cluster) | first -%} -# Bridge for V(X)LANs. -auto {{ bridge.name }} -iface {{ bridge.name }} inet manual - bridge-vlan-aware yes - bridge-ports regex (vni.*) +# bridges must be named vmbrN for proxmox to care +{% for vlan in my_cluster.custom_fields.vlans | sort(attribute='vid') %} +auto vmbr{{ vlan.vid }} +iface vmbr{{ vlan.vid }} inet manual + # {{ vlan.name }} + bridge-vlan-aware no + bridge-ports vni{{ vlan.vid }} bridge-stp off bridge-fd 0 -{% for vid in my_vlan_ids %} -auto vni{{ vid }} -iface vni{{ vid }} inet static - vxlan-id {{ vid }} - bridge-access {{ vid }} +auto vni{{ vlan.vid }} +iface vni{{ vlan.vid }} inet static + vxlan-id {{ vlan.vid }} mstpctl-bpduguard yes mstpctl-portbpdufilter yes {% endfor %} -# In place of vni* interfaces above this should work also but does not. -# Might start working after proxmox upgrades their ifupdown2. -#auto vxlan -#iface vxlan inet static -# bridge-vlan-vni-map {{ my_vlan_ids | zip(my_vlan_ids) | map('join', '=') | join(' ') }} -# bridge-learning off - source /etc/network/interfaces.d/*