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'] }}";