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.
22 lines
633 B
Django/Jinja
22 lines
633 B
Django/Jinja
source /etc/network/interfaces.d/*
|
|
|
|
# Management VRF and link.
|
|
auto mgmt
|
|
iface mgmt
|
|
address 127.0.0.1/8
|
|
address ::1/128
|
|
vrf-table auto
|
|
|
|
{% for iface in hostvars[inventory_hostname].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 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 %}
|