diff --git a/geant/gap_ansible/roles/base_config/tasks/compile_base_config.yaml b/geant/gap_ansible/roles/base_config/tasks/compile_base_config.yaml index 0b75d6be9a5423c3b3daf3303d1f096abcdd176e..fd129021d86ad92b87e963898da7e928f1c17f96 100644 --- a/geant/gap_ansible/roles/base_config/tasks/compile_base_config.yaml +++ b/geant/gap_ansible/roles/base_config/tasks/compile_base_config.yaml @@ -35,6 +35,6 @@ - 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 | ansible.builtin.bool ) is true diff --git a/geant/gap_ansible/roles/base_config/tasks/main.yml b/geant/gap_ansible/roles/base_config/tasks/main.yml index 35d3b0e1187da3a1f862c8943dd772ec3613f1ac..e44b00d6c08ff72cdb20245332dabdf4ec5bb2fa 100644 --- a/geant/gap_ansible/roles/base_config/tasks/main.yml +++ b/geant/gap_ansible/roles/base_config/tasks/main.yml @@ -6,31 +6,29 @@ - "Allowed verbs: 'compile' and 'deploy'. Use: -e 'verb=$verb'." when: (verb is not defined) or (verb not in verbs) +- name: Fail if arguments are missing + ansible.legacy.meta: end_play + when: (verb is not defined) or (verb not in verbs) + +- name: Import routers variables + ansible.builtin.include_vars: + dir: /opt/ansible_inventory/group_vars/routers + +- name: Import variables from 'all' + ansible.builtin.include_vars: + dir: /opt/ansible_inventory/group_vars/all + - name: Set ansible_host to terminal server when router is offline - ansible.legacy.set_fact: + ansible.builtin.set_fact: ansible_host: "{{ wfo_router.router.router_site.site_ts_address }}" ansible_port: "{{ wfo_router.router.router_ts_port }}" when: ( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true -# FIX: Load these vars via group_vars - name: Set variable to connect to nokia - ansible.legacy.set_fact: - ansible_network_os: geant.gap_ansible.sros - ansible_connection: netconf - when: - wfo_router.router.vendor == "nokia" - -- name: Set variables for connecting to Junos - ansible.legacy.set_fact: - ansible_network_os: junos - ansible_connection: netconf - when: - wfo_router.router.vendor == "juniper" - -- name: Fail if arguments are missing - ansible.legacy.meta: end_play - when: (verb is not defined) or (verb not in verbs) + 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 }}" # FIX: this does not work with ncclient 0.6.15 # NOTE: `gather_subset: all` breaks. Workaround to use `min`. @@ -41,16 +39,9 @@ when: wfo_router.router.vendor == "juniper" -- name: Import routers variables - ansible.builtin.include_vars: - dir: /opt/ansible_inventory/group_vars/routers - -- name: Import variables from 'all' - ansible.builtin.include_vars: - dir: /opt/ansible_inventory/group_vars/all - name: Generate an ID for this run - ansible.legacy.set_fact: + ansible.builtin.set_fact: opid: "{{ lookup('community.general.random_string', length=18, special=false) }}" config_is_different: "False" diff --git a/geant/gap_ansible/roles/base_config_checks/tasks/main.yml b/geant/gap_ansible/roles/base_config_checks/tasks/main.yml index 2dc23352e83653503b981d5c5f4dc4348249c124..8091c2d2f5490f659079e6342bf04b28d6be37ad 100644 --- a/geant/gap_ansible/roles/base_config_checks/tasks/main.yml +++ b/geant/gap_ansible/roles/base_config_checks/tasks/main.yml @@ -6,19 +6,14 @@ when: ( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true -- name: Set variable to connect to nokia - ansible.legacy.set_fact: - ansible_network_os: nokia.sros.md - ansible_connection: netconf - when: - wfo_router.router.vendor == "nokia" +- name: Import variables from 'all' + ansible.builtin.include_vars: + dir: /opt/ansible_inventory/group_vars/all -- name: Set variables for connecting to Junos - ansible.legacy.set_fact: - ansible_network_os: junos - ansible_connection: netconf - when: - wfo_router.router.vendor == "juniper" +- name: Set variable to connect to nokia + 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: Execute post-check command [NOKIA] when: 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 8866ec46c43f21767856867f8dbcfff46b93d626..7c46a70acdca7e596a51b9abad3bb0787f8f07c1 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 aa5f1e13f1240109663676a36a78ad12f3cb68d1..e393218ba6d736a1480047cf813f32921e1f6a06 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 5647d7237d3957c786543f6089c918ef0a4ce251..bd6e905ae21f7d3d0081245f33c3dfc3e511b0b1 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 5d23f4f2ba97676eeb737f0553c732aae229009d..c8ef297daa896bf9da843450ec20156d2519d8d0 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: diff --git a/geant/gap_ansible/roles/promote_p_to_pe/tasks/check_routing_instances.yaml b/geant/gap_ansible/roles/promote_p_to_pe/tasks/check_routing_instances.yaml index 653d21d0c0d4c3be22f85b6746bd3397e8417afa..37c5a89e2dc69b8039f2b2bc3f380edd523e2cae 100644 --- a/geant/gap_ansible/roles/promote_p_to_pe/tasks/check_routing_instances.yaml +++ b/geant/gap_ansible/roles/promote_p_to_pe/tasks/check_routing_instances.yaml @@ -1,7 +1,7 @@ - name: Set variable to connect to nokia ansible.builtin.set_fact: - ansible_network_os: nokia.sros.md - ansible_connection: netconf + ansible_connection: "{{ netconf_access[subscription.router.vendor].ansible_connection }}" + ansible_network_os: "{{ netconf_access[subscription.router.vendor].ansible_network_os }}" - name: Check VPRN BGP summary block: diff --git a/geant/gap_ansible/roles/promote_p_to_pe/tasks/compile.yaml b/geant/gap_ansible/roles/promote_p_to_pe/tasks/compile.yaml index 46a463d115d53af2bf99cbddf6acb4eb5eb019fb..995efd31ecf648f16da4165617b95cee9c8e5715 100644 --- a/geant/gap_ansible/roles/promote_p_to_pe/tasks/compile.yaml +++ b/geant/gap_ansible/roles/promote_p_to_pe/tasks/compile.yaml @@ -59,4 +59,4 @@ subscription.router.router_access_via_ts | ansible.builtin.bool ansible.builtin.set_fact: ansible_host: "{{ subscription.router.router_site.site_ts_address }}" - ansible_connection: netconf + ansible_connection: "{{ netconf_access[subscription.router.vendor].ansible_connection }}"