From 5c8f749f7d16a828eb8f6d0e7fd404715b8e0b22 Mon Sep 17 00:00:00 2001 From: J vanBemmel Date: Sun, 1 Dec 2024 01:35:17 -0600 Subject: [PATCH] CL NVUE: Postpone putting interfaces into VRFs until the VRF is created (#1592) --- .../ansible/templates/initial/cumulus_nvue.j2 | 33 ++++--------------- netsim/ansible/templates/vrf/cumulus_nvue.j2 | 22 +++++++++++++ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/netsim/ansible/templates/initial/cumulus_nvue.j2 b/netsim/ansible/templates/initial/cumulus_nvue.j2 index 21f15e2b7..d7d055289 100644 --- a/netsim/ansible/templates/initial/cumulus_nvue.j2 +++ b/netsim/ansible/templates/initial/cumulus_nvue.j2 @@ -14,12 +14,7 @@ {% endif %} {% if i.ipv4 is defined or i.ipv6 is defined %} ip: -{% if i.vrf is defined %} - vrf: {{ i.vrf }} -{% endif %} -{% if i.ipv4 is defined or i.ipv6|default(None) is string %} address: -{% endif %} {% if i.ipv4 is defined %} {% if i.ipv4 == True %} {{ loopback.ipv4 }}: {} @@ -65,38 +60,22 @@ {{ decl_interface(l) }} {% endfor %} -{% for lb in netlab_interfaces if lb.type=='loopback' %} +{% for lb in netlab_interfaces if lb.type=='loopback' and lb.vrf is not defined %} - set: -{% if lb.vrf is not defined %} interface: lo: type: loopback ip: address: -{% if 'ipv4' in lb %} +{% if 'ipv4' in lb %} {{ lb.ipv4 }}: {} -{% else %} +{% else %} 127.0.0.1/8: {} -{% endif %} -{% if 'ipv6' in lb %} +{% endif %} +{% if 'ipv6' in lb %} {{ lb.ipv6 }}: {} -{% else %} +{% else %} ipv6: enable: off -{% endif %} -{% else %} - vrf: - {{ lb.vrf }}: - loopback: - ip: - address: -{% if 'ipv4' in lb %} - {{ lb.ipv4 }}: {} -{% else %} - 127.0.0.1/8: {} -{% endif %} -{% if 'ipv6' in lb %} - {{ lb.ipv6 }}: {} -{% endif %} {% endif %} {% endfor %} diff --git a/netsim/ansible/templates/vrf/cumulus_nvue.j2 b/netsim/ansible/templates/vrf/cumulus_nvue.j2 index e6d7fc43e..1fbf2804f 100644 --- a/netsim/ansible/templates/vrf/cumulus_nvue.j2 +++ b/netsim/ansible/templates/vrf/cumulus_nvue.j2 @@ -12,3 +12,25 @@ {{ vrf_ospf(vname,vdata) }} {% endif %} {% endfor %} + +{% for intf in netlab_interfaces if intf.vrf is defined %} +- set: +{% if intf.type=='loopback' %} + vrf: + {{ intf.vrf }}: + loopback: + ip: + address: +{% if 'ipv4' in intf %} + {{ intf.ipv4 }}: {} +{% endif %} +{% if 'ipv6' in intf %} + {{ intf.ipv6 }}: {} +{% endif %} +{% else %} + interface: + {{ intf.ifname }}: + ip: + vrf: {{ intf.vrf }} +{% endif %} +{% endfor %}