Timotej Lazar
25bcddede1
Consolidate base system and networking setup into debian role and BGP configuration into frr role. Add facts role to collect data from NetBox once to avoid many slow lookups. Also many other tweaks and cleanups.
32 lines
901 B
Django/Jinja
32 lines
901 B
Django/Jinja
{% for vrf in interfaces | selectattr('vrf') | map(attribute='vrf.name') | sort | unique %}
|
|
auto {{ vrf }}
|
|
iface {{ vrf }}
|
|
vrf-table auto
|
|
address 127.0.0.1/8
|
|
address ::1/128
|
|
|
|
{%+ endfor %}
|
|
|
|
{%- for iface in interfaces | selectattr('enabled') %}
|
|
{% if iface.mgmt_only is not defined or not iface.mgmt_only %}
|
|
auto {{ iface.name }}
|
|
iface {{ iface.name }}{% if iface.name == 'lo' %} inet loopback{% endif +%}
|
|
{% if iface.mtu %}
|
|
mtu {{ iface.mtu }}
|
|
{% endif %}
|
|
{% if iface.vrf %}
|
|
vrf {{ iface.vrf.name }}
|
|
{% endif %}
|
|
{% for ip in iface.ip_addresses %}
|
|
address {{ ip.address }}
|
|
{% set subnet = ip.address | ipaddr('subnet') %}
|
|
{% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %}
|
|
{% set gateway = prefix.custom_fields.gateway.address %}
|
|
{% if gateway is defined %}
|
|
gateway {{ gateway | ipaddr('address') }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
{% endfor %}
|