From 004681b553a9734cfb072a09b7fc044cd6a90aa5 Mon Sep 17 00:00:00 2001 From: Julian Labus Date: Fri, 23 Feb 2018 22:27:54 +0100 Subject: [PATCH] Role service-bird: calculate peer addresses of other ansible managed hosts --- roles/service-bird/templates/mwu_ipv4_peers.conf.j2 | 10 +++++++++- roles/service-bird/templates/mwu_ipv6_peers.conf.j2 | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/roles/service-bird/templates/mwu_ipv4_peers.conf.j2 b/roles/service-bird/templates/mwu_ipv4_peers.conf.j2 index 153c36a..c581ab5 100644 --- a/roles/service-bird/templates/mwu_ipv4_peers.conf.j2 +++ b/roles/service-bird/templates/mwu_ipv4_peers.conf.j2 @@ -2,11 +2,19 @@ # {{ ansible_managed }} # +{% for gateway in groups['ffmwu-gateways'] %} +{% if gateway != inventory_hostname %} +protocol bgp mwu_{{ gateway.rsplit('.freifunk-mwu.de')[0] }} from ibgp_mwu { + neighbor {{ bgp_ipv4_transfer_net | ipaddr('net') | ipaddr(hostvars[gateway]['magic']) | ipaddr('ip') }} as mwu_as; +}; + +{% endif %} +{% endfor %} {% for item, value in bgp_mwu_servers.iteritems() %} {% if item != inventory_hostname_short %} protocol bgp mwu_{{ item }} from ibgp_mwu { neighbor {{ value.ipv4 }} as mwu_as; }; -{% endif %} +{% endif %} {% endfor %} diff --git a/roles/service-bird/templates/mwu_ipv6_peers.conf.j2 b/roles/service-bird/templates/mwu_ipv6_peers.conf.j2 index 59051ff..4c20b08 100644 --- a/roles/service-bird/templates/mwu_ipv6_peers.conf.j2 +++ b/roles/service-bird/templates/mwu_ipv6_peers.conf.j2 @@ -2,11 +2,19 @@ # {{ ansible_managed }} # +{% for gateway in groups['ffmwu-gateways'] %} +{% if gateway != inventory_hostname %} +protocol bgp mwu_{{ gateway.rsplit('.freifunk-mwu.de')[0] }} from ibgp_mwu { + neighbor {{ bgp_ipv6_transfer_net | ipaddr('net') | ipsubnet(64, 0) | ipaddr(hostvars[gateway]['magic']) | ipaddr('ip') }} as mwu_as; +}; + +{% endif %} +{% endfor %} {% for item, value in bgp_mwu_servers.iteritems() %} {% if item != inventory_hostname_short %} protocol bgp mwu_{{ item }} from ibgp_mwu { neighbor {{ value.ipv6 }} as mwu_as; }; -{% endif %} +{% endif %} {% endfor %}