template bgp intpeers { local as OWNAS; {% if unicastv4 is defined %} ipv4 { import where source = RTS_BGP && is_valid_network() && !is_self_net(); export where source = RTS_BGP && is_valid_network() && !is_self_net(); next hop self; add paths yes; import table; }; {% endif %} ipv6 { import where source = RTS_BGP && is_valid_network_v6() && !is_self_net_v6(); export where source = RTS_BGP && is_valid_network_v6() && !is_self_net_v6(); next hop self; add paths yes; import table; }; } {% for host in groups['routers'] %} {% if host != inventory_hostname %} protocol bgp int_{{ hostvars[host]['pop_loc'] }} from intpeers { neighbor {{ hostvars[host]['unicastv6'] }} as OWNAS; } {% endif %} {% endfor %}