From 3f725604b6b36e388663be2484bc71ce4cc2e474 Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <aleksandr.kurbatov@GL1342-AKURBATOV.local>
Date: Wed, 21 Aug 2024 18:09:50 +0100
Subject: [PATCH] changes to `ibgp_update` role

2 major types of modifications:
- target is a generated list of routers -> modify_router_list
- target is subscription -> modify_subscription_router

Depending on the inventory passed, the `vendor` var is accessed
differently, hence the need to distinguish (based on the `verb`).
---
 .../roles/ibgp_update/tasks/main.yml          | 19 ++++++--------
 ...y_pe_mesh.yaml => modify_router_list.yaml} |  0
 ...p.yaml => modify_subscription_router.yaml} |  0
 .../ibgp_update/tasks/remove_pe_from_p.yaml   | 25 -------------------
 4 files changed, 8 insertions(+), 36 deletions(-)
 rename geant/gap_ansible/roles/ibgp_update/tasks/{modify_pe_mesh.yaml => modify_router_list.yaml} (100%)
 rename geant/gap_ansible/roles/ibgp_update/tasks/{add_pe_to_p.yaml => modify_subscription_router.yaml} (100%)
 delete mode 100644 geant/gap_ansible/roles/ibgp_update/tasks/remove_pe_from_p.yaml

diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/main.yml b/geant/gap_ansible/roles/ibgp_update/tasks/main.yml
index a4450b05..8c62e6c7 100644
--- a/geant/gap_ansible/roles/ibgp_update/tasks/main.yml
+++ b/geant/gap_ansible/roles/ibgp_update/tasks/main.yml
@@ -35,20 +35,17 @@
   ansible.builtin.debug:
     msg: "{{ opid }}"
 
-- name: Include PE mesh modification tasks
-  ansible.builtin.include_tasks: modify_pe_mesh.yaml
+- name: Include list of routers modification tasks
+  ansible.builtin.include_tasks: modify_router_list.yaml
   when: >
-    verb in [ "add_p_to_pe", "add_pe_to_pe_mesh", "remove_pe_from_pe", "remove_p_from_pe" ]
+    verb in [ "add_p_to_pe", "add_pe_to_pe_mesh", "add_pe_to_all_p",
+            "remove_p_from_pe", "remove_pe_from_pe" ]
 
-- name: Include PE into P tasks if selected
-  ansible.builtin.include_tasks: add_pe_to_p.yaml
+- name: Include single router modification tasks
+  ansible.builtin.include_tasks: modify_subscription_router.yaml
   when: >
-    verb in [ "add_pe_to_p", "verify_p_ibgp", "add_pe_mesh_to_pe" ]
-
-- 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" ]
+    verb in [ "add_pe_to_p", "verify_p_ibgp", "add_pe_mesh_to_pe",
+              "add_all_p_to_pe", "remove_pe_from_p" ]
 
 - name: Check status of iBGP on Nokia router
   ansible.builtin.include_tasks: check_nokia_ibgp.yaml
diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/modify_router_list.yaml
similarity index 100%
rename from geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml
rename to geant/gap_ansible/roles/ibgp_update/tasks/modify_router_list.yaml
diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/add_pe_to_p.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/modify_subscription_router.yaml
similarity index 100%
rename from geant/gap_ansible/roles/ibgp_update/tasks/add_pe_to_p.yaml
rename to geant/gap_ansible/roles/ibgp_update/tasks/modify_subscription_router.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
deleted file mode 100644
index 01aae362..00000000
--- a/geant/gap_ansible/roles/ibgp_update/tasks/remove_pe_from_p.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-# 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
-- 
GitLab