diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/add_p_to_pe.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/add_p_to_pe.yaml deleted file mode 100644 index b63274a376b4bdaaf63c445c263b00d66830cdee..0000000000000000000000000000000000000000 --- a/geant/gap_ansible/roles/ibgp_update/tasks/add_p_to_pe.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# P to PE tasks: -# We need to add the new P to all the PEs -# 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: nokia.sros.md - 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 - ansible.builtin.include_tasks: compile.yaml - -- name: Include deploy tasks - ansible.builtin.include_tasks: deploy.yaml diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/main.yml b/geant/gap_ansible/roles/ibgp_update/tasks/main.yml index 3fe519471853b89bc8fc816fc4d59809d9272695..bbe8fb8a8cdf3d301c4c6bfa6db65c65e2f7ec4e 100644 --- a/geant/gap_ansible/roles/ibgp_update/tasks/main.yml +++ b/geant/gap_ansible/roles/ibgp_update/tasks/main.yml @@ -23,15 +23,21 @@ ansible.builtin.debug: msg: "{{ opid }}" -- name: Include P into PEs tasks if selected - ansible.builtin.include_tasks: add_p_to_pe.yaml - when: verb == "add_p_to_pe" +- name: Include PE mesh modification tasks + ansible.builtin.include_tasks: modify_pe_mesh.yaml + when: > + verb in [ "add_p_to_pe", "remove_pe_from_pe", "remove_p_from_pe" ] - name: Include PE into P tasks if selected ansible.builtin.include_tasks: add_pe_to_p.yaml when: > verb in [ "add_pe_to_p", "verify_p_ibgp" ] +- 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" ] + - name: Check status of iBGP on P router ansible.builtin.include_tasks: check_p_ibgp.yaml when: verb == "check_p_ibgp" diff --git a/geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml b/geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5647d7237d3957c786543f6089c918ef0a4ce251 --- /dev/null +++ b/geant/gap_ansible/roles/ibgp_update/tasks/modify_pe_mesh.yaml @@ -0,0 +1,23 @@ +# P to PE tasks: +# We need to add the new P to all the PEs +# 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" + +- name: Include compile tasks + ansible.builtin.include_tasks: compile.yaml + +- name: Include deploy tasks + ansible.builtin.include_tasks: deploy.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 new file mode 100644 index 0000000000000000000000000000000000000000..01aae362b1ccc5826c36e50d98e165933bc097bb --- /dev/null +++ b/geant/gap_ansible/roles/ibgp_update/tasks/remove_pe_from_p.yaml @@ -0,0 +1,25 @@ +# 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 diff --git a/geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_p_from_pe.j2 b/geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_p_from_pe.j2 new file mode 100644 index 0000000000000000000000000000000000000000..0a139d34d9206da6cb197936779ec4f17775cdd0 --- /dev/null +++ b/geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_p_from_pe.j2 @@ -0,0 +1,2 @@ +delete protocols bgp group iGEANT6-P-ONLY neighbor {{ p_lo_ipv6_address }} +delete protocols bgp group iGEANT-P-ONLY neighbor {{ p_lo_ipv4_address }} diff --git a/geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_pe_from_pe.j2 b/geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_pe_from_pe.j2 new file mode 100644 index 0000000000000000000000000000000000000000..9bd780dd826aa532f672683543211a61c869787e --- /dev/null +++ b/geant/gap_ansible/roles/ibgp_update/templates/juniper/remove_pe_from_pe.j2 @@ -0,0 +1,2 @@ +delete protocols bgp group iGEANT6 neighbor {{ subscription.router.router_lo_ipv6_address }} +delete protocols bgp group iGEANT neighbor {{ subscription.router.router_lo_ipv4_address }} diff --git a/geant/gap_ansible/roles/ibgp_update/templates/nokia/add_pe_to_p.j2 b/geant/gap_ansible/roles/ibgp_update/templates/nokia/add_pe_to_p.j2 index 2b9528d8b7b36c151c7fe877b15fdde5d42e4768..198b8878514b5203a7af263af07df1d4e261ac5c 100644 --- a/geant/gap_ansible/roles/ibgp_update/templates/nokia/add_pe_to_p.j2 +++ b/geant/gap_ansible/roles/ibgp_update/templates/nokia/add_pe_to_p.j2 @@ -3,7 +3,7 @@ <router> <router-name>Base</router-name> <bgp> - {% for pe_fqdn, pe_ipadd in pe_router_list.items() %} + {% for pe_fqdn, pe_ipadd in pe_router_list.all.hosts.items() %} <neighbor xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes" alu:operation="replace"> <ip-address>{{ pe_ipadd.lo4 }}</ip-address> <description>{{ pe_fqdn }}</description> diff --git a/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_p.j2 b/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_p.j2 new file mode 100644 index 0000000000000000000000000000000000000000..07672c2bfc3955686044a5b52893498681590dfa --- /dev/null +++ b/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_p.j2 @@ -0,0 +1,15 @@ +<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> + <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> + <router xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> + <router-name>Base</router-name> + <bgp xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> + <neighbor alu:operation="delete"> + <ip-address>{{ subscription.router.router_lo_ipv4_address }}</ip-address> + </neighbor> + <neighbor alu:operation="delete"> + <ip-address>{{ subscription.router.router_lo_ipv6_address }}</ip-address> + </neighbor> + </bgp> + </router> + </configure> +</config> diff --git a/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_pe.j2 b/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_pe.j2 new file mode 100644 index 0000000000000000000000000000000000000000..48242b15b64be09b6891a1aabcc9bfc49917d4a8 --- /dev/null +++ b/geant/gap_ansible/roles/ibgp_update/templates/nokia/remove_pe_from_pe.j2 @@ -0,0 +1,17 @@ +<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> + <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> + <router> + <router-name>Base</router-name> + <bgp xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> + <neighbor alu:operation="delete"> + <ip-address>{{ subscription.router.router_lo_ipv4_address }}</ip-address> + <group>iGEANT</group> + </neighbor> + <neighbor alu:operation="delete"> + <ip-address>{{ subscription.router.router_lo_ipv6_address }}</ip-address> + <group>iGEANT6</group> + </neighbor> + </bgp> + </router> + </configure> +</config> diff --git a/geant/gap_ansible/roles/ibgp_update/vars/main.yml b/geant/gap_ansible/roles/ibgp_update/vars/main.yml index e118a3ef5d659ab367562d790c51cb4e3d68c389..6b064e84bb607c60b346aaee9c191d74504472f6 100644 --- a/geant/gap_ansible/roles/ibgp_update/vars/main.yml +++ b/geant/gap_ansible/roles/ibgp_update/vars/main.yml @@ -8,9 +8,10 @@ verbs: - check_p_ibgp - verify_p_ibgp # Validates the config of BGP stanza including neighbors - remove_p_from_pe # placeholder for future use | Removes the P that is going to be promoted to PE from the P-GROUP on all PEs + - remove_pe_from_p # PE router termination workflow + - remove_pe_from_pe # When decommissiong a PE we remove it from PE-GROUP and P-GROUP on all the PE and P routers - add_pe_to_pe # placeholder for future use | Adds the newly installed PE (could be an EX-P or a new PE) to the PE-GROUP on all the other PEs - add_new_pe_to_p # placeholder for future use | Adds the newly installed PE (could be an EX-P or a new PE) the P-GROUP on all the Ps - - remove_pe_from_net # placeholder for future use | When decommissiong a PE we remove it from PE-GROUP and P-GROUP on all the PE and P routers - promote_p_to_pe # placeholder for future use | Deletes P-GROUP and adds wfo_router: "{{ subscription }}" p_lo_ipv4_address: "{{ wfo_router.router.router_lo_ipv4_address }}"