proxmox: get all data from netbox

This commit is contained in:
Timotej Lazar 2023-11-20 12:56:34 +01:00
parent 62a3dc5121
commit 2d89cd730c
3 changed files with 17 additions and 20 deletions

View file

@ -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 %}

View file

@ -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/*

View file

@ -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 %}