running-config on the switch:
switch-1#
interface Ethernet1/1
ip dhcp relay address 1.1.1.2
j2 template:
{% for ip in dhcp_servers %}
interface Ethernet1/1
ip dhcp relay address {{ ip }}
{% endfor %}
variables defined:
dhcp_servers:
- 1.1.1.2
- 1.1.1.3
- 1.1.1.4
expected config created with j2, later to be added on the switch:
interface Ethernet1/1
ip dhcp relay address 1.1.1.3
ip dhcp relay address 1.1.1.4
Only creating configs which are not present in the running config without needing to delete the ip from variable list (dhcp_servers)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…