network/roles/fabric/templates/interfaces.j2
Timotej Lazar 9c35f0fa25 fabric: get mgmt gateway from custom field on prefix
Mainly so we can add IPv6 addresses to mgmt interfaces.
2025-03-24 18:13:20 +01:00

27 lines
697 B
Django/Jinja

source /etc/network/interfaces.d/*.intf
# Management VRF and interface.
auto mgmt
iface mgmt
address 127.0.0.1/8
address 127.0.1.1/8
address ::1/128
vrf-table auto
{% for iface in interfaces | selectattr('mgmt_only') | selectattr('enabled') %}
auto {{ iface.name }}
iface {{ iface.name }}
vrf mgmt
ip-forward off
ip6-forward off
{% for ip in iface.ip_addresses %}
address {{ ip.address }}
{% set subnet = ip.address | ipaddr('subnet') %}
{% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %}
{% if prefix.custom_fields.gateway %}
gateway {{ prefix.custom_fields.gateway.address | ipaddr('address') }}
{% endif %}
{% endfor %}
{% endfor %}