June 2017
Intermediate to advanced
446 pages
10h 10m
English
We can also loop through a list as well as a dictionary as we have completed in the last section; make the following changes in nxos.j2:
{% for vlan_num in item.value.vlans %} vlan {{ vlan_num }} {% endfor %} {% for vlan_interface in item.value.vlan_interfaces %} interface {{ vlan_interface.int_num }} ip address {{ vlan_interface.ip }}/24 {% endfor %}
Provide the additional list and dictionary variables in the playbook:
vars: nexus_devices: { "nx-osv-1": { "hostname": "nx-osv-1", "username": "cisco", "password": "cisco", "vlans": [100, 200, 300], "vlan_interfaces": [ {"int_num": "100", "ip": "192.168.10.1"}, {"int_num": "200", "ip": "192.168.20.1"}, {"int_num": "300", "ip": "192.168.30.1"} ] } }
Run the playbook, and you will ...
Read now
Unlock full access