Skip to content
Snippets Groups Projects
Commit 037ab6ad authored by Simone Spinelli's avatar Simone Spinelli
Browse files

Merge branch 'fix/ansible-connection-private-config' into 'develop'

Fix/ansible connection private config

See merge request !189
parents 5c5bbeaa 0a060222
No related branches found
No related tags found
1 merge request!189Fix/ansible connection private config
Pipeline #90277 passed
...@@ -35,6 +35,6 @@ ...@@ -35,6 +35,6 @@
- name: Set back ansible_host to target terminal server - name: Set back ansible_host to target terminal server
ansible.builtin.set_fact: ansible.builtin.set_fact:
ansible_host: "{{ wfo_router.router.router_site.site_ts_address }}" ansible_host: "{{ wfo_router.router.router_site.site_ts_address }}"
ansible_connection: netconf ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}"
when: when:
( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true ( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true
...@@ -6,31 +6,29 @@ ...@@ -6,31 +6,29 @@
- "Allowed verbs: 'compile' and 'deploy'. Use: -e 'verb=$verb'." - "Allowed verbs: 'compile' and 'deploy'. Use: -e 'verb=$verb'."
when: (verb is not defined) or (verb not in verbs) 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 - 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_host: "{{ wfo_router.router.router_site.site_ts_address }}"
ansible_port: "{{ wfo_router.router.router_ts_port }}" ansible_port: "{{ wfo_router.router.router_ts_port }}"
when: when:
( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true ( 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 - name: Set variable to connect to nokia
ansible.legacy.set_fact: ansible.builtin.set_fact:
ansible_network_os: geant.gap_ansible.sros ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}"
ansible_connection: netconf ansible_network_os: "{{ netconf_access[wfo_router.router.vendor].ansible_network_os }}"
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)
# FIX: this does not work with ncclient 0.6.15 # FIX: this does not work with ncclient 0.6.15
# NOTE: `gather_subset: all` breaks. Workaround to use `min`. # NOTE: `gather_subset: all` breaks. Workaround to use `min`.
...@@ -41,16 +39,9 @@ ...@@ -41,16 +39,9 @@
when: when:
wfo_router.router.vendor == "juniper" 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 - 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) }}" opid: "{{ lookup('community.general.random_string', length=18, special=false) }}"
config_is_different: "False" config_is_different: "False"
......
...@@ -6,19 +6,14 @@ ...@@ -6,19 +6,14 @@
when: when:
( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true ( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true
- name: Set variable to connect to nokia - name: Import variables from 'all'
ansible.legacy.set_fact: ansible.builtin.include_vars:
ansible_network_os: nokia.sros.md dir: /opt/ansible_inventory/group_vars/all
ansible_connection: netconf
when:
wfo_router.router.vendor == "nokia"
- name: Set variables for connecting to Junos - name: Set variable to connect to nokia
ansible.legacy.set_fact: ansible.builtin.set_fact:
ansible_network_os: junos ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}"
ansible_connection: netconf ansible_network_os: "{{ netconf_access[wfo_router.router.vendor].ansible_network_os }}"
when:
wfo_router.router.vendor == "juniper"
- name: Execute post-check command [NOKIA] - name: Execute post-check command [NOKIA]
when: when:
......
- name: Set variable to connect to nokia - name: Set variable to connect to nokia
ansible.legacy.set_fact: ansible.legacy.set_fact:
ansible_network_os: nokia.sros.md ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}"
ansible_connection: netconf ansible_network_os: "{{ netconf_access[wfo_router.router.vendor].ansible_network_os }}"
- name: Check BGP status - name: Check BGP status
block: block:
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
- name: Set back ansible_host to target terminal server - name: Set back ansible_host to target terminal server
ansible.builtin.set_fact: ansible.builtin.set_fact:
ansible_host: "{{ wfo_router.router.router_site.site_ts_address }}" ansible_host: "{{ wfo_router.router.router_site.site_ts_address }}"
ansible_connection: netconf ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}"
when: when:
wfo_router.router.router_access_via_ts is defined and wfo_router.router.router_access_via_ts is defined and
( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true ( wfo_router.router.router_access_via_ts | ansible.builtin.bool ) is true
......
...@@ -3,18 +3,9 @@ ...@@ -3,18 +3,9 @@
# PEs can be either Juniper or Nokia # PEs can be either Juniper or Nokia
- name: Adjust network connection according to the vendor - name: Adjust network connection according to the vendor
block: ansible.builtin.set_fact:
- name: Set variable to connect to nokia ansible_connection: "{{ netconf_access[wfo_router.router.vendor].ansible_connection }}"
ansible.legacy.set_fact: ansible_network_os: "{{ netconf_access[wfo_router.router.vendor].ansible_network_os }}"
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: Include compile tasks - name: Include compile tasks
ansible.builtin.include_tasks: compile.yaml ansible.builtin.include_tasks: compile.yaml
......
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
# We need to add all the existing PE the new P # We need to add all the existing PE the new P
# P routers will always be NOKIA # P routers will always be NOKIA
# In this case you have wfo_router as external variable # 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 - name: Set variable to connect to nokia
ansible.builtin.set_fact: ansible.builtin.set_fact:
ansible_network_os: geant.gap_ansible.sros ansible_connection: "{{ netconf_access[subscription.router.vendor].ansible_connection }}"
ansible_connection: netconf ansible_network_os: "{{ netconf_access[subscription.router.vendor].ansible_network_os }}"
- name: Set ansible_host to terminal server when router is offline - name: Set ansible_host to terminal server when router is offline
ansible.builtin.set_fact: ansible.builtin.set_fact:
......
- name: Set variable to connect to nokia - name: Set variable to connect to nokia
ansible.builtin.set_fact: ansible.builtin.set_fact:
ansible_network_os: nokia.sros.md ansible_connection: "{{ netconf_access[subscription.router.vendor].ansible_connection }}"
ansible_connection: netconf ansible_network_os: "{{ netconf_access[subscription.router.vendor].ansible_network_os }}"
- name: Check VPRN BGP summary - name: Check VPRN BGP summary
block: block:
......
...@@ -59,4 +59,4 @@ ...@@ -59,4 +59,4 @@
subscription.router.router_access_via_ts | ansible.builtin.bool subscription.router.router_access_via_ts | ansible.builtin.bool
ansible.builtin.set_fact: ansible.builtin.set_fact:
ansible_host: "{{ subscription.router.router_site.site_ts_address }}" ansible_host: "{{ subscription.router.router_site.site_ts_address }}"
ansible_connection: netconf ansible_connection: "{{ netconf_access[subscription.router.vendor].ansible_connection }}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment