#
# {{ ansible_managed }}
#

{% for network in my_wireguard_networks %}
protocol bgp mwu_{{ network.remote }} from ibgp_mwu {
{% if magic < network.remote_magic %}
    source address {{ network.ipv4 | ipaddr('address') }};
    neighbor {{ network.ipv4 | ipaddr('1') | ipaddr('address') }} as mwu_as;
{% else %}
    source address {{ network.ipv4 | ipaddr('1') | ipaddr('address') }};
    neighbor {{ network.ipv4 | ipaddr('address') }} as mwu_as;
{% endif %}
};

{% endfor %}

{% if server_type == 'gateway' %}
{% for item, value in bgp_legacy_servers.items() %}
{% if item != inventory_hostname_short %}
protocol bgp mwu_{{ item }}_legacy from ibgp_mwu {
    source address mwu_address_legacy;
    neighbor {{ value.ipv4 }} as mwu_as;
};

{% endif %}
{% endfor %}
{% endif %}