diff --git a/roles/proxmox/templates/frr.conf.j2 b/roles/proxmox/templates/frr.conf.j2 index 89ad8c1..c40ea00 100644 --- a/roles/proxmox/templates/frr.conf.j2 +++ b/roles/proxmox/templates/frr.conf.j2 @@ -5,14 +5,14 @@ log syslog # We only have the default route, so allow talking to BGP peers over it. ip nht resolve-via-default -router bgp {{ hostvars[inventory_hostname].custom_fields.asn.asn }} +router bgp {{ asn.asn }} bgp bestpath as-path multipath-relax neighbor fabric peer-group neighbor fabric remote-as external neighbor fabric capability extended-nexthop -{% for iface in hostvars[inventory_hostname].interfaces | selectattr('name', 'match', '^lan') %} +{% for iface in interfaces | selectattr('name', 'match', '^lan') %} neighbor {{ iface.name }} interface peer-group fabric neighbor {{ iface.name }} bfd {% endfor %} diff --git a/roles/proxmox/templates/interfaces.j2 b/roles/proxmox/templates/interfaces.j2 index 6ae0dbb..d21f582 100644 --- a/roles/proxmox/templates/interfaces.j2 +++ b/roles/proxmox/templates/interfaces.j2 @@ -1,19 +1,20 @@ -# Keep vmbr0 named as is and in the main interfaces file so Proxmox can find it. +{# 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 -%} # Bridge for V(X)LANs. -auto vmbr0 -iface vmbr0 inet manual +auto {{ bridge.name }} +iface {{ bridge.name }} inet manual bridge-vlan-aware yes bridge-ports regex (vni.*) bridge-stp off bridge-fd 0 -# Interfaces. -{% for vlan in vlans %} -auto vni{{ vlan }} -iface vni{{ vlan }} inet static - vxlan-id {{ vlan }} - bridge-access {{ vlan }} +{% for vid in my_vlan_ids %} +auto vni{{ vid }} +iface vni{{ vid }} inet static + vxlan-id {{ vid }} + bridge-access {{ vid }} mstpctl-bpduguard yes mstpctl-portbpdufilter yes @@ -23,8 +24,7 @@ iface vni{{ vlan }} inet static # Might start working after proxmox upgrades their ifupdown2. #auto vxlan #iface vxlan inet static -# bridge-vlan-vni-map {{ vlans | zip(vlans) | map('join', '=') | join(' ') }} -# bridge-vids {{ vlans | join(' ') }} +# bridge-vlan-vni-map {{ my_vlan_ids | zip(my_vlan_ids) | map('join', '=') | join(' ') }} # bridge-learning off source /etc/network/interfaces.d/* diff --git a/roles/proxmox/templates/mgmt.intf.j2 b/roles/proxmox/templates/mgmt.intf.j2 index e15567d..3622f4d 100644 --- a/roles/proxmox/templates/mgmt.intf.j2 +++ b/roles/proxmox/templates/mgmt.intf.j2 @@ -5,19 +5,16 @@ iface mgmt address ::1/128 vrf-table auto -{% for iface in hostvars[inventory_hostname].interfaces | selectattr('name', 'match', '^mgmt') | selectattr('ip_addresses') %} +{% for iface in interfaces | selectattr('name', 'match', '^mgmt') | selectattr('ip_addresses') %} auto {{ iface.name }} iface {{ iface.name }} vrf mgmt {% for ip in iface.ip_addresses %} address {{ ip.address }} -{% set subnet = ip.address | ipaddr('subnet') %} -{% set prefix = query('netbox.netbox.nb_lookup', 'prefixes', api_filter=('prefix='+subnet))|first %} -{% set gateway = prefix.value.custom_fields.gateway.address %} -{% if gateway is defined %} - gateway {{ gateway | ipaddr('address') }} +{% endfor %} +{% if iface.custom_fields.gateway %} + gateway {{ iface.custom_fields.gateway.address | ipaddr('address') }} {% endif %} -{% endfor %} {% endfor %}