proxmox: get all data from netbox
This commit is contained in:
parent
62a3dc5121
commit
2d89cd730c
|
@ -5,14 +5,14 @@ log syslog
|
||||||
# We only have the default route, so allow talking to BGP peers over it.
|
# We only have the default route, so allow talking to BGP peers over it.
|
||||||
ip nht resolve-via-default
|
ip nht resolve-via-default
|
||||||
|
|
||||||
router bgp {{ hostvars[inventory_hostname].custom_fields.asn.asn }}
|
router bgp {{ asn.asn }}
|
||||||
bgp bestpath as-path multipath-relax
|
bgp bestpath as-path multipath-relax
|
||||||
|
|
||||||
neighbor fabric peer-group
|
neighbor fabric peer-group
|
||||||
neighbor fabric remote-as external
|
neighbor fabric remote-as external
|
||||||
neighbor fabric capability extended-nexthop
|
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 }} interface peer-group fabric
|
||||||
neighbor {{ iface.name }} bfd
|
neighbor {{ iface.name }} bfd
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -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.
|
# Bridge for V(X)LANs.
|
||||||
auto vmbr0
|
auto {{ bridge.name }}
|
||||||
iface vmbr0 inet manual
|
iface {{ bridge.name }} inet manual
|
||||||
bridge-vlan-aware yes
|
bridge-vlan-aware yes
|
||||||
bridge-ports regex (vni.*)
|
bridge-ports regex (vni.*)
|
||||||
bridge-stp off
|
bridge-stp off
|
||||||
bridge-fd 0
|
bridge-fd 0
|
||||||
|
|
||||||
# Interfaces.
|
{% for vid in my_vlan_ids %}
|
||||||
{% for vlan in vlans %}
|
auto vni{{ vid }}
|
||||||
auto vni{{ vlan }}
|
iface vni{{ vid }} inet static
|
||||||
iface vni{{ vlan }} inet static
|
vxlan-id {{ vid }}
|
||||||
vxlan-id {{ vlan }}
|
bridge-access {{ vid }}
|
||||||
bridge-access {{ vlan }}
|
|
||||||
mstpctl-bpduguard yes
|
mstpctl-bpduguard yes
|
||||||
mstpctl-portbpdufilter yes
|
mstpctl-portbpdufilter yes
|
||||||
|
|
||||||
|
@ -23,8 +24,7 @@ iface vni{{ vlan }} inet static
|
||||||
# Might start working after proxmox upgrades their ifupdown2.
|
# Might start working after proxmox upgrades their ifupdown2.
|
||||||
#auto vxlan
|
#auto vxlan
|
||||||
#iface vxlan inet static
|
#iface vxlan inet static
|
||||||
# bridge-vlan-vni-map {{ vlans | zip(vlans) | map('join', '=') | join(' ') }}
|
# bridge-vlan-vni-map {{ my_vlan_ids | zip(my_vlan_ids) | map('join', '=') | join(' ') }}
|
||||||
# bridge-vids {{ vlans | join(' ') }}
|
|
||||||
# bridge-learning off
|
# bridge-learning off
|
||||||
|
|
||||||
source /etc/network/interfaces.d/*
|
source /etc/network/interfaces.d/*
|
||||||
|
|
|
@ -5,19 +5,16 @@ iface mgmt
|
||||||
address ::1/128
|
address ::1/128
|
||||||
vrf-table auto
|
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 }}
|
auto {{ iface.name }}
|
||||||
iface {{ iface.name }}
|
iface {{ iface.name }}
|
||||||
vrf mgmt
|
vrf mgmt
|
||||||
{% for ip in iface.ip_addresses %}
|
{% for ip in iface.ip_addresses %}
|
||||||
address {{ ip.address }}
|
address {{ ip.address }}
|
||||||
{% set subnet = ip.address | ipaddr('subnet') %}
|
{% endfor %}
|
||||||
{% set prefix = query('netbox.netbox.nb_lookup', 'prefixes', api_filter=('prefix='+subnet))|first %}
|
{% if iface.custom_fields.gateway %}
|
||||||
{% set gateway = prefix.value.custom_fields.gateway.address %}
|
gateway {{ iface.custom_fields.gateway.address | ipaddr('address') }}
|
||||||
{% if gateway is defined %}
|
|
||||||
gateway {{ gateway | ipaddr('address') }}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue