Skip to content

Instantly share code, notes, and snippets.

@jeffbrl
Last active January 25, 2017 03:20
Show Gist options
  • Save jeffbrl/740d3951aea2890890be5b64a61f7035 to your computer and use it in GitHub Desktop.
Save jeffbrl/740d3951aea2890890be5b64a61f7035 to your computer and use it in GitHub Desktop.
Looping examples in jinja2
#jinja2: lstrip_blocks: True
{% set vlans_per_ifl = 10 %}
{% for ifd, int in host.uplinks.items() %}
{{ ifd }} {
description "{{ int.description }}";
apply-groups-except interface-properties;
vlan-tagging;
mtu 9432;
encapsulation flexible-ethernet-services;
{% for count in range(1,vlans_per_ifl + 1) %}
unit {{ count + 100 }} {
encapsulation vlan-ccc;
vlan-id {{ count + 100 }}
}
{% endfor %}
{% endfor %}
host:
management:
ip: 10.10.10.1
mask: 24
description: "Management Interface"
loopback:
ip: 5.5.5.1
mask: 32
uplinks:
em1:
ip: 172.16.0.0
mask: 31
description: "From router1 to router2"
em2:
ip: 172.168.0.1
mask: 31
description: "From router2 to router3"
iso_address: "47.0005.80bb.f800.0000.0001.0001.0000.0000.2509.00"
router_id: 192.168.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment