From e38c09bc09bc60412a3568ca35cae645e2319f56 Mon Sep 17 00:00:00 2001 From: Daniel Ankers Date: Fri, 19 Jan 2024 16:50:24 +0000 Subject: [PATCH] Only configure relevant VLANs on any switch --- juniper-macros.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/juniper-macros.j2 b/juniper-macros.j2 index 320e76d..62d3cc5 100644 --- a/juniper-macros.j2 +++ b/juniper-macros.j2 @@ -302,7 +302,8 @@ routing-options { {% macro vlanssection(vlans,device) %} vlans { -{% for vlan in vlans %} +{# This next line selects all of the VLANs which are configured on this device #} +{% for vlan in vlans if (device['interfaces']|selectattr('untagged_vlan.vid','equalto',vlan)|list|count or interfaces|map(attribute='tagged_vlans')|sum(start=[])|selectattr('vid','equalto',vlan)|list|count) or device['interfaces']|selectattr('name', 'equalto', 'irb.'+vlan['vid']|string)|list|count %} vl{{ vlan['vid'] }} { {% if vlan['name'] != '' %} description "{{ vlan['name'] }}";