0

Yaml template

bgp:
      local: 109
      remote: 109
      site:
         - neighbor:
              peer_ip: [ 172.16.110.3, 172.16.110.4 ]
           vpnv4:
              vrf: Site-1
              network: 109.10.1.1
              mask: 255.255.255.0
         - neighbor:
              peer_ip: [ 172.16.120.3, 172.16.120.4 ]
           vpnv4:
              vrf: Site-2
              network: 109.10.1.1
              mask: 255.255.255.0

Jinja2 template

router bgp {{ item.bgp.local }}
{% for i in item.bgp.site %}
 address-family ipv4 vrf {{ i.vpnv4.vrf }}
 network {{ i.vpnv4.network }} mask {{ i.vpnv4.mask }}
{% for b in item.bgp.site.neighbor.peer_ip %}
 neighbor {{ b }} remote-as {{ item.bgp.remote }}
 neighbor {{ b }} activate
{% endfor %}
{% endfor %}

If I remove this it works. I am suspecting an issue with "list" but no idea how to fix it.

{% for b in item.bgp.site.neighbor.peer_ip %}
 neighbor {{ b }} remote-as {{ item.bgp.remote }}
 neighbor {{ b }} activate
{% endfor %}
1
  • Which list are you referring to? How are you invoking ansible? Commented Feb 11, 2017 at 20:49

1 Answer 1

1

item.bgp.site is actually i of your outer loop.

Try: {% for b in i.neighbor.peer_ip %}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.