Vote count: 0
Here is the yaml template:
static_routes:
- network: 1.1.1.0
mask: 255.255.255.0
next_hop: 19.19.3.10
- network: 7.7.32.0
mask: 255.255.255.0
next_hop: 7.7.2.1
- network: 172.16.110.0
mask: 255.255.255.248
intf: FastEthernet0/1.1
next_hop: 172.16.110.3
- network: 172.16.120.0
mask: 255.255.255.248
intf: FastEthernet0/1.2
next_hop: 172.16.120.3
- network: 150.1.7.4
mask: 255.255.255.255
intf: FastEthernet0/0.1
next_hop: 19.19.3.10
vrf: Site-1
glob: global
- network: 150.1.7.4
mask: 255.255.255.255
next_hop: 19.19.3.10
vrf: Site-1
- network: 150.1.7.4
mask: 255.255.255.255
next_hop: 19.19.3.10
intf: FastEthernet0/0.1
glob: global
vrf: Site-2
- network: 150.1.7.4
mask: 255.255.255.255
next_hop: 19.19.3.10
vrf: Site-2
Jinja2 template (notice repetitive if statement and wondering if there is a way to combine it in one to get the desired output below)
The final output will look like this:
ip route 1.1.1.0 255.255.255.0 19.19.3.10
ip route 7.7.32.0 255.255.255.0 7.7.2.1
ip route 172.16.110.0 255.255.255.248 FastEthernet0/1.1 172.16.110.3
ip route 172.16.120.0 255.255.255.248 FastEthernet0/1.2 172.16.120.3
ip route vrf Site-1 150.1.7.4 255.255.255.255 FastEthernet0/0.1 19.19.3.10 global
ip route vrf Site-1 150.1.7.4 255.255.255.255 19.19.3.10
ip route vrf Site-2 150.1.7.4 255.255.255.255 FastEthernet0/0.1 19.19.3.10 global
ip route vrf Site-2 150.1.7.4 255.255.255.255 19.19.3.10
This piece of code works, but wondering if there is a way to simplify Jinja2 conditions for this type of scenario?
asked 36 secs ago
Jinja2 for loop and complex conditions
Aucun commentaire:
Enregistrer un commentaire