debian: get inventory data from netbox
Set standardized interface names (mgmt0… for L2 management interfaces and lan0… for L3 data interfaces speaking BGP). ASN is stored as a custom field in netbox but that might change.
This commit is contained in:
parent
2330edf479
commit
63ab087645
7 changed files with 69 additions and 48 deletions
|
@ -1,6 +1,6 @@
|
|||
{% for iface in ifaces_fabric %}
|
||||
auto {{ iface }}
|
||||
iface {{ iface }}
|
||||
{% for iface in hostvars[inventory_hostname].interfaces | selectattr('name', 'match', '^lan') %}
|
||||
auto {{ iface.name }}
|
||||
iface {{ iface.name }}
|
||||
mtu 9216
|
||||
|
||||
{% endfor %}
|
|
@ -2,16 +2,16 @@ frr defaults datacenter
|
|||
service integrated-vtysh-config
|
||||
log syslog
|
||||
|
||||
router bgp {{ asn }}
|
||||
router bgp {{ hostvars[inventory_hostname].custom_fields.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 ifaces_fabric %}
|
||||
neighbor {{ iface }} interface peer-group fabric
|
||||
neighbor {{ iface }} bfd
|
||||
{% for iface in hostvars[inventory_hostname].interfaces | selectattr('name', 'match', '^lan') %}
|
||||
neighbor {{ iface.name }} interface peer-group fabric
|
||||
neighbor {{ iface.name }} bfd
|
||||
{% endfor %}
|
||||
|
||||
address-family ipv4 unicast
|
||||
|
|
|
@ -7,8 +7,16 @@ iface mgmt
|
|||
address ::1/128
|
||||
vrf-table auto
|
||||
|
||||
auto {{ iface_mgmt }}
|
||||
iface {{ iface_mgmt }}
|
||||
{% for iface in hostvars[inventory_hostname].interfaces | selectattr('name', 'match', '^mgmt') | selectattr('ip_addresses') %}
|
||||
auto {{ iface.name }}
|
||||
iface {{ iface.name }}
|
||||
vrf mgmt
|
||||
address {{ ansible_host }}/{{ mgmt_gw | ipaddr('prefix') }}
|
||||
gateway {{ mgmt_gw | ipaddr('address') }}
|
||||
{% for ip in iface.ip_addresses %}
|
||||
address {{ ip.address }}
|
||||
{% set gw = query('netbox.netbox.nb_lookup', 'ip-addresses', api_filter=('tag=gateway parent=' + ip.address))|first %}
|
||||
{% if gw is defined %}
|
||||
gateway {{ gw.value.address | ipaddr('address') }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
{% set iface_lo = hostvars[inventory_hostname].interfaces | selectattr('name', 'equalto', 'lo') | first %}
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
address {{ router_id }}/32
|
||||
{% for ip in iface_lo.ip_addresses %}
|
||||
address {{ ip.address }}
|
||||
{% endfor %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue