From 4ef224e8e37f10f2601b0c9cd84fce1a49ac0840 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <aleksandr.kurbatov@GL1342-AKURBATOV.local> Date: Thu, 25 Jul 2024 14:35:05 +0100 Subject: [PATCH] Termination workflow Tested cases: - Add P routers to PE - Terminate a PE (will remove PE from PE-mesh, and remove PE from P-routers). --- .../roles/ibgp_update/tasks/main.yml | 11 ++++---- .../ibgp_update/tasks/modify_pe_mesh.yaml | 21 ++++++++-------- .../ibgp_update/tasks/remove_pe_from_p.yaml | 25 +++++++++++++++++++ ...ve_pe_from_net.j2 => remove_pe_from_pe.j2} | 0 .../templates/nokia/add_pe_to_p.j2 | 2 +- .../templates/nokia/remove_pe_from_p.j2 | 10 +++----- ...ve_pe_from_net.j2 => remove_pe_from_pe.j2} | 0 .../roles/ibgp_update/vars/main.yml | 2 +- 8 files changed, 47 insertions(+), 24 deletions(-) create mode 100644 geant/gap_ansible/roles/ibgp_update/tasks/remove_pe_from_p.yaml rename geant/gap_ansible/roles/ibgp_update/templates/juniper/{remove_pe_from_net.j2 => remove_pe_from_pe.j2} (100%) rename geant/gap_ansible/roles/ibgp_update/templates/nokia/{remove_pe_from_net.j2 => remove_pe_from_pe.j2} (100%) diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/main.yml b/geant/gap_ansible/roles/ibgp_update/tasks/main.yml index eb64cdb2..bbe8fb8a 100644 --- a/geant/gap_ansible/roles/ibgp_update/tasks/main.yml +++ b/geant/gap_ansible/roles/ibgp_update/tasks/main.yml @@ -23,20 +23,21 @@ ansible.builtin.debug: msg: "{{ opid }}" -- name: Include P into PEs tasks if selected - ansible.builtin.include_tasks: add_p_to_pe.yaml - when: verb == "add_p_to_pe" - - name: Include PE mesh modification tasks ansible.builtin.include_tasks: modify_pe_mesh.yaml when: > - verb in [ "add_p_to_pe", "remove_pe_from_net", "remove_p_from_pe" ] + verb in [ "add_p_to_pe", "remove_pe_from_pe", "remove_p_from_pe" ] - name: Include PE into P tasks if selected ansible.builtin.include_tasks: add_pe_to_p.yaml when: > verb in [ "add_pe_to_p", "verify_p_ibgp" ] +- name: Include PE removal from P tasks if selected + ansible.builtin.include_tasks: remove_pe_from_p.yaml + when: > + verb in [ "remove_pe_from_p" ] + - name: Check status of iBGP on P router ansible.builtin.include_tasks: check_p_ibgp.yaml when: verb == "check_p_ibgp" diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml index 7b8bcaff..5647d723 100644 --- a/geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml +++ b/geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml @@ -4,18 +4,17 @@ - name: Adjust network connection according to the vendor block: - # - - name: Set variable to connect to nokia - ansible.legacy.set_fact: - ansible_network_os: geant.gap_ansible.sros - ansible_connection: netconf - when: vendor == "nokia" + - name: Set variable to connect to nokia + ansible.legacy.set_fact: + ansible_network_os: geant.gap_ansible.sros + ansible_connection: netconf + when: vendor == "nokia" - - name: Set variables for connecting to Junos - ansible.legacy.set_fact: - ansible_network_os: junos - ansible_connection: netconf - when: vendor == "juniper" + - name: Set variables for connecting to Junos + ansible.legacy.set_fact: + ansible_network_os: junos + ansible_connection: netconf + when: vendor == "juniper" - name: Include compile tasks ansible.builtin.include_tasks: compile.yaml diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/remove_pe_from_p.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/remove_pe_from_p.yaml new file mode 100644 index 00000000..01aae362 --- /dev/null +++ b/geant/gap_ansible/roles/ibgp_update/tasks/remove_pe_from_p.yaml @@ -0,0 +1,25 @@ +# PE to P tasks: +# This is th case of decomm of a PE router <- remove it from all Ps. +# P routers will always be NOKIA +# FIX: Load ansible_network_os via group_vars +# +- name: Set variable to connect to nokia + ansible.legacy.set_fact: + ansible_network_os: geant.gap_ansible.sros + ansible_connection: netconf + +# - name: Set ansible_host to terminal server when router is offline +# ansible.legacy.set_fact: +# ansible_host: "{{ subscription.router.router_site.site_ts_address }}" +# ansible_port: "{{ subscription.router.router_ts_port }}" +# when: ( subscription.router.router_access_via_ts | ansible.builtin.bool ) is true + +- name: Set vendor var for "remove_pe_from_p" case + ansible.builtin.set_fact: + vendor: "nokia" + +- name: Include compile tasks + ansible.builtin.include_tasks: compile.yaml + +- name: Include deploy tasks + ansible.builtin.include_tasks: deploy.yaml diff --git a/geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_pe_from_net.j2 b/geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_pe_from_pe.j2 similarity index 100% rename from geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_pe_from_net.j2 rename to geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_pe_from_pe.j2 diff --git a/geant/gap_ansible/roles/ibgp_update/templates/nokia/add_pe_to_p.j2 b/geant/gap_ansible/roles/ibgp_update/templates/nokia/add_pe_to_p.j2 index 2b9528d8..198b8878 100644 --- a/geant/gap_ansible/roles/ibgp_update/templates/nokia/add_pe_to_p.j2 +++ b/geant/gap_ansible/roles/ibgp_update/templates/nokia/add_pe_to_p.j2 @@ -3,7 +3,7 @@ <router> <router-name>Base</router-name> <bgp> - {% for pe_fqdn, pe_ipadd in pe_router_list.items() %} + {% for pe_fqdn, pe_ipadd in pe_router_list.all.hosts.items() %} <neighbor xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes" alu:operation="replace"> <ip-address>{{ pe_ipadd.lo4 }}</ip-address> <description>{{ pe_fqdn }}</description> diff --git a/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_p.j2 b/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_p.j2 index 088de3ea..07672c2b 100644 --- a/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_p.j2 +++ b/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_p.j2 @@ -1,15 +1,13 @@ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> - <router> + <router xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> <router-name>Base</router-name> - <bgp> - <neighbor xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes" alu:operation="delete"> + <bgp xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> + <neighbor alu:operation="delete"> <ip-address>{{ subscription.router.router_lo_ipv4_address }}</ip-address> - <group>iGEANT-P-ONLY</group> </neighbor> - <neighbor xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes" alu:operation="delete"> + <neighbor alu:operation="delete"> <ip-address>{{ subscription.router.router_lo_ipv6_address }}</ip-address> - <group>iGEANT6-P-ONLY</group> </neighbor> </bgp> </router> diff --git a/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_net.j2 b/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_pe.j2 similarity index 100% rename from geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_net.j2 rename to geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_pe.j2 diff --git a/geant/gap_ansible/roles/ibgp_update/vars/main.yml b/geant/gap_ansible/roles/ibgp_update/vars/main.yml index caaa1231..6b064e84 100644 --- a/geant/gap_ansible/roles/ibgp_update/vars/main.yml +++ b/geant/gap_ansible/roles/ibgp_update/vars/main.yml @@ -9,7 +9,7 @@ verbs: - verify_p_ibgp # Validates the config of BGP stanza including neighbors - remove_p_from_pe # placeholder for future use | Removes the P that is going to be promoted to PE from the P-GROUP on all PEs - remove_pe_from_p # PE router termination workflow - - remove_pe_from_net # When decommissiong a PE we remove it from PE-GROUP and P-GROUP on all the PE and P routers + - remove_pe_from_pe # When decommissiong a PE we remove it from PE-GROUP and P-GROUP on all the PE and P routers - add_pe_to_pe # placeholder for future use | Adds the newly installed PE (could be an EX-P or a new PE) to the PE-GROUP on all the other PEs - add_new_pe_to_p # placeholder for future use | Adds the newly installed PE (could be an EX-P or a new PE) the P-GROUP on all the Ps - promote_p_to_pe # placeholder for future use | Deletes P-GROUP and adds -- GitLab