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"