From 6e24a72e5cef83fa2457db436dae271bec6fd231 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <ak@geant.org> Date: Mon, 11 Nov 2024 10:43:16 +0000 Subject: [PATCH] `ansible_connection` in ibgp_update --- .../roles/ibgp_update/tasks/check_nokia_ibgp.yaml | 4 ++-- .../roles/ibgp_update/tasks/compile.yaml | 2 +- .../ibgp_update/tasks/modify_router_list.yaml | 15 +++------------ .../tasks/modify_subscription_router.yaml | 5 ++--- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/check_nokia_ibgp.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/check_nokia_ibgp.yaml index 8866ec46..7c46a70a 100644 --- a/geant/gap_ansible/roles/ibgp_update/tasks/check_nokia_ibgp.yaml +++ b/geant/gap_ansible/roles/ibgp_update/tasks/check_nokia_ibgp.yaml @@ -1,7 +1,7 @@ - name: Set variable to connect to nokia ansible.legacy.set_fact: - ansible_network_os: nokia.sros.md - ansible_connection: netconf + ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}" + ansible_network_os: "{{ netconf_access[wfo_router.router.vendor].ansible_network_os }}" - name: Check BGP status block: diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/compile.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/compile.yaml index aa5f1e13..e393218b 100644 --- a/geant/gap_ansible/roles/ibgp_update/tasks/compile.yaml +++ b/geant/gap_ansible/roles/ibgp_update/tasks/compile.yaml @@ -26,7 +26,7 @@ - name: Set back ansible_host to target terminal server ansible.builtin.set_fact: ansible_host: "{{ wfo_router.router.router_site.site_ts_address }}" - ansible_connection: netconf + ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}" when: wfo_router.router.router_access_via_ts is defined and ( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/modify_router_list.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/modify_router_list.yaml index 5647d723..bd6e905a 100644 --- a/geant/gap_ansible/roles/ibgp_update/tasks/modify_router_list.yaml +++ b/geant/gap_ansible/roles/ibgp_update/tasks/modify_router_list.yaml @@ -3,18 +3,9 @@ # PEs can be either Juniper or Nokia - 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 variables for connecting to Junos - ansible.legacy.set_fact: - ansible_network_os: junos - ansible_connection: netconf - when: vendor == "juniper" + ansible.builtin.set_fact: + ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}" + ansible_network_os: "{{ netconf_access[wfo_router.router.vendor].ansible_network_os }}" - name: Include compile tasks ansible.builtin.include_tasks: compile.yaml diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/modify_subscription_router.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/modify_subscription_router.yaml index 5d23f4f2..c8ef297d 100644 --- a/geant/gap_ansible/roles/ibgp_update/tasks/modify_subscription_router.yaml +++ b/geant/gap_ansible/roles/ibgp_update/tasks/modify_subscription_router.yaml @@ -2,12 +2,11 @@ # We need to add all the existing PE the new P # P routers will always be NOKIA # In this case you have wfo_router as external variable -# FIX: Load ansible_network_os via group_vars # - name: Set variable to connect to nokia ansible.builtin.set_fact: - ansible_network_os: geant.gap_ansible.sros - ansible_connection: netconf + ansible_connection: "{{ netconf_access[subscription.router.vendor].ansible_connection }}" + ansible_network_os: "{{ netconf_access[subscription.router.vendor].ansible_network_os }}" - name: Set ansible_host to terminal server when router is offline ansible.builtin.set_fact: -- GitLab