From 9029653baa84d8e2f9eb79a363fe97d800c1a732 Mon Sep 17 00:00:00 2001 From: Maor Blaustein Date: Tue, 5 May 2026 16:45:13 +0300 Subject: [PATCH] Add eBGP leaf template support for BGP dt02 Allow parameterized leaf ASN and downlink peering mode in the leaf FRR template. Conditional route-reflector-client for iBGP racks only, since FRR rejects it on eBGP peers (different ASN). Adds ebgp_racks and ebgp_leaf_asn variables to control which racks use eBGP and their leaf ASN (formula: 64999 - rack_id). Applies to both IPv4 and IPv6 address families. Adds bgp_dt02 template symlink for ci_gen_kustomize_values. Related: OSPRH-28085 Assisted-By: Claude Code Signed-off-by: Maor Blaustein --- playbooks/bgp/prepare-bgp-spines-leaves.yaml | 5 +++++ playbooks/bgp/templates/leaf-frr.conf.j2 | 17 +++++++++++++---- .../ci_gen_kustomize_values/templates/bgp_dt02 | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) create mode 120000 roles/ci_gen_kustomize_values/templates/bgp_dt02 diff --git a/playbooks/bgp/prepare-bgp-spines-leaves.yaml b/playbooks/bgp/prepare-bgp-spines-leaves.yaml index 53bea8643..db42a5ead 100644 --- a/playbooks/bgp/prepare-bgp-spines-leaves.yaml +++ b/playbooks/bgp/prepare-bgp-spines-leaves.yaml @@ -453,6 +453,11 @@ leaf_id: "{{ (ansible_hostname.split('-')[-1] | int) % 2 }}" # always 2 leaves per rack rack_id: "{{ (ansible_hostname.split('-')[-1] | int) // 2 }}" # always 2 leaves per rack _ip_version: "{{ ip_version | default(4) | int }}" + # ebgp_racks: comma-separated rack IDs that use eBGP (e.g. "1,2") + # ebgp_leaf_asn: base ASN for eBGP leaves (default: 64999 - rack_id) + _is_ebgp_rack: "{{ (rack_id | int) in (ebgp_racks | default('') | split(',') | select | map('int') | list) }}" + downlink_remote_as: "{{ 'external' if _is_ebgp_rack else 'internal' }}" + leaf_asn: "{{ ebgp_leaf_asn | default(64999 - (rack_id | int)) if _is_ebgp_rack else 64999 }}" tasks: - name: Obtain the connection for the eth0 interface ansible.builtin.command: diff --git a/playbooks/bgp/templates/leaf-frr.conf.j2 b/playbooks/bgp/templates/leaf-frr.conf.j2 index d4405b0c4..c72568913 100644 --- a/playbooks/bgp/templates/leaf-frr.conf.j2 +++ b/playbooks/bgp/templates/leaf-frr.conf.j2 @@ -13,12 +13,15 @@ debug bgp neighbor-events debug bgp updates debug bgp update-groups -router bgp 64999 +{% set _downlink_as_mode = downlink_remote_as | default('internal') %} +router bgp {{ leaf_asn | default(64999) }} {% if _router_id %} bgp router-id {{_router_id}} {% endif %} bgp log-neighbor-changes +{% if _downlink_as_mode == 'internal' %} bgp graceful-shutdown +{% endif %} bgp graceful-restart bgp graceful-restart notification @@ -27,7 +30,7 @@ router bgp 64999 ! bgp long-lived-graceful-restart stale-time 15 neighbor downlink peer-group - neighbor downlink remote-as internal + neighbor downlink remote-as {{ _downlink_as_mode }} neighbor downlink bfd neighbor downlink bfd profile tripleo {# TODO: remove the next if when RHEL-63205 is fixed #} @@ -53,9 +56,11 @@ router bgp 64999 address-family ipv4 unicast redistribute connected - neighbor downlink route-reflector-client neighbor downlink default-originate neighbor downlink next-hop-self +{% if _downlink_as_mode == 'internal' %} + neighbor downlink route-reflector-client +{% endif %} neighbor downlink prefix-list only-host-prefixes out neighbor uplink allowas-in origin neighbor uplink prefix-list only-default-host-prefixes in @@ -64,9 +69,11 @@ router bgp 64999 address-family ipv6 unicast redistribute connected neighbor downlink activate - neighbor downlink route-reflector-client neighbor downlink default-originate neighbor downlink next-hop-self +{% if _downlink_as_mode == 'internal' %} + neighbor downlink route-reflector-client +{% endif %} neighbor uplink activate neighbor uplink allowas-in origin neighbor uplink prefix-list only-default-host-prefixes in @@ -76,7 +83,9 @@ router bgp 64999 neighbor uplink activate neighbor uplink allowas-in origin neighbor downlink activate +{% if _downlink_as_mode == 'internal' %} neighbor downlink route-reflector-client +{% endif %} exit-address-family ip prefix-list only-default-host-prefixes permit 0.0.0.0/0 diff --git a/roles/ci_gen_kustomize_values/templates/bgp_dt02 b/roles/ci_gen_kustomize_values/templates/bgp_dt02 new file mode 120000 index 000000000..5df68da8a --- /dev/null +++ b/roles/ci_gen_kustomize_values/templates/bgp_dt02 @@ -0,0 +1 @@ +bgp_dt01 \ No newline at end of file