From 7d89d70342dd8512bc9580d855eb186e4309d691 Mon Sep 17 00:00:00 2001 From: Carlos Goncalves Date: Tue, 19 Jan 2021 10:02:00 +0100 Subject: [PATCH] Set source IPv4 address from inventory vars Currently users have to pass in a dictionary of HOSTNAME:SOURCE_IPV4 of all nodes in the deployment. An example is as follows from THT: FrrBgpIpv4LoopbackMap: ctrl-1-0: 99.99.1.1 ctrl-2-0: 99.99.2.1 ctrl-3-0: 99.99.3.1 cmp-1-0: 99.99.1.2 cmp-2-0: 99.99.2.2 cmp-3-0: 99.99.3.2 cmp-1-1: 99.99.1.3 cmp-2-1: 99.99.2.3 cmp-3-1: 99.99.3.3 This is rather time consuming, prone to typos and requires updating at node scale up/down. It would be much easier if users could just pass in the network and have tripleo_frr get the IP from given network. Snip from tripleo-ansible-inventory.yaml: ControllerRack1: hosts: ctrl-1-0: {ansible_host: 192.168.1.101, canonical_hostname: ctrl-1-0.bgp.ftw, main_network_hostname: ctrl-1-0.mainnetwork.bgp.ftw, main_network_ip: 99.99.1.1, [...] Change-Id: I43852cb3570b8cb12a35f4bc641a42ddfd8ad7f1 --- tripleo_ansible/roles/tripleo_frr/defaults/main.yml | 2 +- tripleo_ansible/roles/tripleo_frr/templates/frr.conf.j2 | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tripleo_ansible/roles/tripleo_frr/defaults/main.yml b/tripleo_ansible/roles/tripleo_frr/defaults/main.yml index 2f821ac50..a12c18d96 100644 --- a/tripleo_ansible/roles/tripleo_frr/defaults/main.yml +++ b/tripleo_ansible/roles/tripleo_frr/defaults/main.yml @@ -23,6 +23,7 @@ tripleo_frr_bfd: false tripleo_frr_bgp: false tripleo_frr_bgp_ipv4: true tripleo_frr_bgp_ipv4_allowas_in: false +tripleo_frr_bgp_ipv4_src_network: ctlplane tripleo_frr_bgp_ipv6: true tripleo_frr_bgp_ipv6_allowas_in: false tripleo_frr_bgp_uplinks_scope: internal @@ -31,4 +32,3 @@ tripleo_frr_hostname: "{{ ansible_hostname }}" tripleo_frr_log_level: informational tripleo_frr_watchfrr: true tripleo_frr_zebra: false -tripleo_frr_bgp_ipv4_default_src_map: {} diff --git a/tripleo_ansible/roles/tripleo_frr/templates/frr.conf.j2 b/tripleo_ansible/roles/tripleo_frr/templates/frr.conf.j2 index b9e67098e..abe4e7652 100644 --- a/tripleo_ansible/roles/tripleo_frr/templates/frr.conf.j2 +++ b/tripleo_ansible/roles/tripleo_frr/templates/frr.conf.j2 @@ -44,13 +44,11 @@ router bgp {{ tripleo_frr_bgp_asn }} ip prefix-list only-default permit 0.0.0.0/0 ip prefix-list only-host-prefixes permit 0.0.0.0/0 ge 32 -{% if tripleo_frr_bgp_ipv4_default_src_map|length > 0 and tripleo_frr_hostname in tripleo_frr_bgp_ipv4_default_src_map %} route-map rm-only-default permit 10 match ip address prefix-list only-default - set src {{ tripleo_frr_bgp_ipv4_default_src_map[tripleo_frr_hostname] }} + set src {{ hostvars[inventory_hostname][tripleo_frr_bgp_ipv4_src_network ~ '_ip'] }} ip protocol bgp route-map rm-only-default -{% endif %} {# tripleo_frr_bgp_ipv4_default_src_map #} {% endif %} {# tripleo_frr_bgp_ipv4 #} {% if tripleo_frr_bgp_ipv6 %}