From 9c35f0fa25dcfd21b66c145d60531edf8c52c494 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 23 Mar 2025 19:51:25 +0100 Subject: [PATCH] fabric: get mgmt gateway from custom field on prefix Mainly so we can add IPv6 addresses to mgmt interfaces. --- roles/fabric/templates/interfaces.j2 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/roles/fabric/templates/interfaces.j2 b/roles/fabric/templates/interfaces.j2 index ba69d7b..384992b 100644 --- a/roles/fabric/templates/interfaces.j2 +++ b/roles/fabric/templates/interfaces.j2 @@ -14,11 +14,13 @@ iface {{ iface.name }} vrf mgmt ip-forward off ip6-forward off -{% for ip in iface.ip_addresses | rejectattr('address', 'match', '^fe80::.*/64$' ) %} +{% for ip in iface.ip_addresses %} address {{ ip.address }} -{% endfor %} -{% if iface.custom_fields.gateway %} - gateway {{ iface.custom_fields.gateway.address | ipaddr('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 %}