diff --git a/geant/gap_ansible/roles/iptrunk_checks/tasks/check_bfd.yaml b/geant/gap_ansible/roles/iptrunk_checks/tasks/check_bfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c7feac4e2a956da5a0d94d0e58367f517cc1f58e --- /dev/null +++ b/geant/gap_ansible/roles/iptrunk_checks/tasks/check_bfd.yaml @@ -0,0 +1,31 @@ +- name: Juniper BFD check + when: local_side.iptrunk_side_node.vendor == "juniper" + block: + - name: Get status of BFD for neighbor "{{ new_node.router.router_lo_ipv4_address }}" + junipernetworks.junos.junos_command: + commands: + - show bfd session address "{{ new_node.router.router_lo_ipv4_address }}" + register: response + + - name: Show status of BFD neigbor + ansible.builtin.debug: + msg: "{{ response.stdout_lines[0] }}" + +- name: Nokia BFD check + when: local_side.iptrunk_side_node.vendor == "nokia" + block: + - name: Get status of BFD for neighbor "{{ new_node.router.router_lo_ipv4_address }}" + ansible.netcommon.netconf_rpc: + rpc: action + xmlns: "urn:ietf:params:xml:ns:yang:1" + content: | + <global-operations xmlns="urn:nokia.com:sros:ns:yang:sr:oper-global"> + <md-cli-raw-command> + <md-cli-input-line>show lag {{ local_side.iptrunk_side_ae_iface | lower }} bfd</md-cli-input-line> + </md-cli-raw-command> + </global-operations> + display: json + register: out + - name: Show BFD status + ansible.builtin.debug: + msg: "{{out.output['rpc-reply']['nokiaoper:results']['nokiaoper:md-cli-output-block'].split('\n')}}" diff --git a/geant/gap_ansible/roles/iptrunk_checks/tasks/main.yml b/geant/gap_ansible/roles/iptrunk_checks/tasks/main.yml index 5f0e90ccb2e56037cfd121f9a77927cb71ed28f2..ec17edd49f493126be41b2bc72d71be0dd2046fb 100644 --- a/geant/gap_ansible/roles/iptrunk_checks/tasks/main.yml +++ b/geant/gap_ansible/roles/iptrunk_checks/tasks/main.yml @@ -81,6 +81,10 @@ ansible.builtin.include_tasks: check_trunk_interface.yaml when: check == "ping" +- name: Check BFD + ansible.builtin.include_tasks: check_bfd.yaml + when: check == "bfd" + - name: Set the optical checks results directory name when: check == "optical_pre" or check == "optical_post" ansible.builtin.set_fact: diff --git a/geant/gap_ansible/roles/iptrunk_checks/vars/main.yml b/geant/gap_ansible/roles/iptrunk_checks/vars/main.yml index cb53fc84bb373f4b44ebb3e11ce9ad65e724a090..18a050f94a1f9e112424710e6e01c869274b5f3a 100644 --- a/geant/gap_ansible/roles/iptrunk_checks/vars/main.yml +++ b/geant/gap_ansible/roles/iptrunk_checks/vars/main.yml @@ -2,6 +2,7 @@ # vars file for iptrunks # checks: + - bfd - isis - ping - lacp diff --git a/geant/gap_ansible/roles/iptrunk_migration/tasks/bfd_update.yaml b/geant/gap_ansible/roles/iptrunk_migration/tasks/bfd_update.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1a31076c5e2f25a42e619311f46cb25138986011 --- /dev/null +++ b/geant/gap_ansible/roles/iptrunk_migration/tasks/bfd_update.yaml @@ -0,0 +1,24 @@ +--- +- name: Update Trunk interface BFD on "{{ inventory_hostname }}" [CHECK ONLY][JUNIPER] + junipernetworks.junos.junos_config: + update: 'replace' + src: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf" + src_format: set + check_commit: true + diff: true + when: > + verb == "update" and + remaining_side.vendor == "juniper" and + dry_run | ansible.builtin.bool + +- name: Update Trunk interface BFD on "{{ inventory_hostname }}" [AND COMMIT][JUNIPER] + junipernetworks.junos.junos_config: + update: 'replace' + src: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf" + src_format: set + comment: "{{ commit_comment }}" + diff: true + when: > + verb == "update" and + remaining_side.vendor == "juniper" and + not (dry_run | ansible.builtin.bool) diff --git a/geant/gap_ansible/roles/iptrunk_migration/tasks/compile_template.yaml b/geant/gap_ansible/roles/iptrunk_migration/tasks/compile_template.yaml index da370805d4f18cdf6f6c4241d59b1a3762bdd53a..80e59fe72ce21a8147d987979f5b2261ab9a647e 100644 --- a/geant/gap_ansible/roles/iptrunk_migration/tasks/compile_template.yaml +++ b/geant/gap_ansible/roles/iptrunk_migration/tasks/compile_template.yaml @@ -40,6 +40,16 @@ delegate_to: localhost when: (verb == "deploy") and inventory_hostname == new_node.router.router_fqdn +- name: Print template for the remaining node in "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf" + ansible.builtin.template: + src: "{{ remaining_side.vendor }}/{{ config_object }}.j2" + dest: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf" + lstrip_blocks: true + trim_blocks: true + mode: '0755' + delegate_to: localhost + when: (verb == "update") and inventory_hostname == remaining_side.name + - name: Set netconf connection for trunk nodes ansible.builtin.include_tasks: set_netconf_connection.yaml when: verb == "delete" or verb == "deactivate" diff --git a/geant/gap_ansible/roles/iptrunk_migration/tasks/main.yml b/geant/gap_ansible/roles/iptrunk_migration/tasks/main.yml index 9474d27a6c5024cbd1a740214478f5911dd07577..1ca1cd481f901475e058a24485912f34c940aee5 100644 --- a/geant/gap_ansible/roles/iptrunk_migration/tasks/main.yml +++ b/geant/gap_ansible/roles/iptrunk_migration/tasks/main.yml @@ -35,11 +35,11 @@ - name: Calculate local side ansible.builtin.include_tasks: calculate_local_side.yaml - when: (verb == "delete" or verb == "deactivate") and inventory_hostname != new_node.router.router_fqdn + when: (verb in ["delete", "deactivate", "update"]) and inventory_hostname != new_node.router.router_fqdn - name: Set netconf connection for trunk nodes ansible.builtin.include_tasks: set_netconf_connection.yaml - when: (verb == "delete" or verb == "deactivate") and inventory_hostname != new_node.router.router_fqdn + when: (verb in ["delete", "deactivate", "update"]) and inventory_hostname != new_node.router.router_fqdn - name: Set ansible_host connection for new side ansible.builtin.set_fact: @@ -80,3 +80,11 @@ - name: Include the deployment tasks if specified ansible.builtin.include_tasks: deploy_object.yaml when: verb == "deploy" and inventory_hostname == new_node.router.router_fqdn + +- name: Compile update for the remaining node (BFD update) + ansible.builtin.include_tasks: compile_template.yaml + when: verb == "update" and inventory_hostname == remaining_side.name + +- name: Include update for the remaining node (BFD update) + ansible.builtin.include_tasks: bfd_update.yaml + when: verb == "update" and inventory_hostname == remaining_side.name diff --git a/geant/gap_ansible/roles/iptrunk_migration/tasks/set_netconf_connection.yaml b/geant/gap_ansible/roles/iptrunk_migration/tasks/set_netconf_connection.yaml index 47f7abadc1424f30e2052306fdf0ec743c7d6f6e..c5f887050b78fbc6e0766fd4302d6d2f3cdf2aae 100644 --- a/geant/gap_ansible/roles/iptrunk_migration/tasks/set_netconf_connection.yaml +++ b/geant/gap_ansible/roles/iptrunk_migration/tasks/set_netconf_connection.yaml @@ -3,4 +3,4 @@ ansible_host: "{{ local_side.iptrunk_side_node.router_site.site_ts_address }}" ansible_port: "{{ local_side.iptrunk_side_node.router_ts_port }}" when: - ( local_side.iptrunk_side_node.router_access_via_ts | ansible.builtin.bool ) is true + local_side.iptrunk_side_node.router_access_via_ts | ansible.builtin.bool diff --git a/geant/gap_ansible/roles/iptrunk_migration/templates/juniper/bfd_update.j2 b/geant/gap_ansible/roles/iptrunk_migration/templates/juniper/bfd_update.j2 new file mode 100644 index 0000000000000000000000000000000000000000..69dc5039d546ec132ac306b516c54f30c11e6cde --- /dev/null +++ b/geant/gap_ansible/roles/iptrunk_migration/templates/juniper/bfd_update.j2 @@ -0,0 +1,2 @@ + +set interfaces {{ remaining_side.ae_name }} aggregated-ether-options bfd-liveness-detection neighbor {{ new_node.router.router_lo_ipv4_address }} diff --git a/geant/gap_ansible/roles/iptrunk_migration/vars/main.yml b/geant/gap_ansible/roles/iptrunk_migration/vars/main.yml index 565ba579ab88b5cc77ba5c00c60453c13574ad0d..36c89b858847f5efa3b76729e00db0808ba479a2 100644 --- a/geant/gap_ansible/roles/iptrunk_migration/vars/main.yml +++ b/geant/gap_ansible/roles/iptrunk_migration/vars/main.yml @@ -6,6 +6,7 @@ verbs: - "deactivate" - "deploy" - "delete" + - "update" config_objects: - "deactivate" @@ -13,6 +14,7 @@ config_objects: - "trunk_interface" - "isis_interface" - "trunk_deprovision" + - "bfd_update" bfd_min_interval: 3000 mtu_phy: 9212 @@ -46,4 +48,6 @@ new_side: remaining_side: name: "{{ wfo_trunk.iptrunk.iptrunk_sides[1 - (replace_index | int)].iptrunk_side_node.router_fqdn }}" + vendor: "{{ wfo_trunk.iptrunk.iptrunk_sides[1 - (replace_index | int)].iptrunk_side_node.vendor }}" loopback: "{{ wfo_trunk.iptrunk.iptrunk_sides[1 - (replace_index | int)].iptrunk_side_node.router_lo_ipv4_address }}" + ae_name: "{{ wfo_trunk.iptrunk.iptrunk_sides[1 - (replace_index | int)].iptrunk_side_ae_iface }}"