From 202f5be171debb1823eedfaceaa1011546eeed6d Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <ak@geant.org> Date: Thu, 5 Dec 2024 12:15:38 +0000 Subject: [PATCH 1/5] deploy: set ansible_host back to inventory_hostname --- .../roles/deploy_service_config/tasks/connection_tasks.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/geant/gap_ansible/roles/deploy_service_config/tasks/connection_tasks.yml b/geant/gap_ansible/roles/deploy_service_config/tasks/connection_tasks.yml index 6dd169a3..cef17805 100644 --- a/geant/gap_ansible/roles/deploy_service_config/tasks/connection_tasks.yml +++ b/geant/gap_ansible/roles/deploy_service_config/tasks/connection_tasks.yml @@ -5,6 +5,11 @@ ansible_port: "{{ router.router_ts_port }}" when: router.router_access_via_ts | ansible.builtin.bool +- name: Set ansible_host back to the {{ inventory_hostname }} + when: not router.router_access_via_ts | ansible.builtin.bool + ansible.builtin.set_fact: + ansible_host: "{{ inventory_hostname }}" + - name: Load netconf connection config ansible.builtin.set_fact: ansible_connection: "{{ netconf_access[router.vendor].ansible_connection }}" -- GitLab From e6465ec96d6551e0d6744d3a5eb37c43e1d5fd94 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <ak@geant.org> Date: Thu, 5 Dec 2024 18:37:58 +0000 Subject: [PATCH 2/5] PE base-config: include EGEANT groups --- .../gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 index f45754dc..17db9b18 100644 --- a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 +++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/bgp.j2 @@ -10,6 +10,9 @@ {% with bgp_obj=pe_bgp_internal, bgp_group_context='bgp_base' %} {% include "router/bgp_group.j2" %} {% endwith %} + {% with bgp_obj=pe_bgp_egeant, bgp_group_context='bgp_base' %} + {% include "router/bgp_group.j2" %} + {% endwith %} {% else %} {% with bgp_base_obj=p_bgp_base, bgp_obj=p_bgp_internal, bgp_context='bgp_base', bgp_group_context='bgp_base' %} -- GitLab From 4dc92479d2c4166b546822763d1313a4431f387d Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <ak@geant.org> Date: Thu, 5 Dec 2024 18:38:22 +0000 Subject: [PATCH 3/5] edge_port: add encapsulation to the template --- .../roles/edge_port/templates/nokia/edge_port_create.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_create.j2 b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_create.j2 index 296e9fbc..af6f3156 100644 --- a/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_create.j2 +++ b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_create.j2 @@ -8,6 +8,7 @@ <description>PHY {{ ep.edge_port_type }} {{ partner_name }} P_{{ ep.edge_port_name }} | {{ member.interface_description }}</description> <ethernet> <mode>access</mode> + <encap-type>{{ ep.encapsulation }}</encap-type> <mtu>{{ mtu_phy | default(9192) }}</mtu> {% if edge_port_lldp_enable_map[ep.edge_port_type] is true %} <lldp> @@ -37,6 +38,7 @@ <lag 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"> <lag-name>{{ ep.edge_port_name | lower }}</lag-name> <admin-state>enable</admin-state> + <encap-type>{{ ep.encapsulation }}</encap-type> {% if ep.geant_ga_id is string %} <description>LAG {{ ep.edge_port_type }} {{ partner_name }} ${{ ep.geant_ga_id }} |</description> {% else %} -- GitLab From 3a067f87a1e24fe873229fd08591ef11bb3e1780 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <ak@geant.org> Date: Thu, 5 Dec 2024 18:38:37 +0000 Subject: [PATCH 4/5] service_checks: new role --- .../roles/service_checks/README.md | 38 +++++++++++++++++++ .../roles/service_checks/defaults/main.yml | 4 ++ .../roles/service_checks/meta/main.yml | 34 +++++++++++++++++ .../service_checks/tasks/bgp_checks.yaml | 18 +++++++++ .../roles/service_checks/tasks/main.yml | 15 ++++++++ .../service_checks/tasks/sbp_checks.yaml | 18 +++++++++ .../roles/service_checks/vars/main.yml | 4 ++ 7 files changed, 131 insertions(+) create mode 100644 geant/gap_ansible/roles/service_checks/README.md create mode 100644 geant/gap_ansible/roles/service_checks/defaults/main.yml create mode 100644 geant/gap_ansible/roles/service_checks/meta/main.yml create mode 100644 geant/gap_ansible/roles/service_checks/tasks/bgp_checks.yaml create mode 100644 geant/gap_ansible/roles/service_checks/tasks/main.yml create mode 100644 geant/gap_ansible/roles/service_checks/tasks/sbp_checks.yaml create mode 100644 geant/gap_ansible/roles/service_checks/vars/main.yml diff --git a/geant/gap_ansible/roles/service_checks/README.md b/geant/gap_ansible/roles/service_checks/README.md new file mode 100644 index 00000000..225dd44b --- /dev/null +++ b/geant/gap_ansible/roles/service_checks/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/geant/gap_ansible/roles/service_checks/defaults/main.yml b/geant/gap_ansible/roles/service_checks/defaults/main.yml new file mode 100644 index 00000000..693a16ca --- /dev/null +++ b/geant/gap_ansible/roles/service_checks/defaults/main.yml @@ -0,0 +1,4 @@ +--- +# defaults file for service_checks +sbp_ping_count: 10 +sbp_ping_size: 512 diff --git a/geant/gap_ansible/roles/service_checks/meta/main.yml b/geant/gap_ansible/roles/service_checks/meta/main.yml new file mode 100644 index 00000000..51500bc4 --- /dev/null +++ b/geant/gap_ansible/roles/service_checks/meta/main.yml @@ -0,0 +1,34 @@ +galaxy_info: + author: A. Kurbatov + description: GOAT engineer + company: GEANT + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: MIT + + min_ansible_version: '2.10' + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + galaxy_tags: ['network'] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/geant/gap_ansible/roles/service_checks/tasks/bgp_checks.yaml b/geant/gap_ansible/roles/service_checks/tasks/bgp_checks.yaml new file mode 100644 index 00000000..1408690f --- /dev/null +++ b/geant/gap_ansible/roles/service_checks/tasks/bgp_checks.yaml @@ -0,0 +1,18 @@ +--- +- name: Check BGP neigbor + 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 router bgp neighbor "{{ neighbor.peer_address }}"</md-cli-input-line> + </md-cli-raw-command> + </global-operations> + display: json + register: out + +- name: Show ping results + when: "'nokiaoper:results' in out.output.['rpc-reply']" + ansible.builtin.debug: + msg: "{{out.output['rpc-reply']['nokiaoper:results']['nokiaoper:md-cli-output-block'].split('\n')}}" diff --git a/geant/gap_ansible/roles/service_checks/tasks/main.yml b/geant/gap_ansible/roles/service_checks/tasks/main.yml new file mode 100644 index 00000000..a6554fdd --- /dev/null +++ b/geant/gap_ansible/roles/service_checks/tasks/main.yml @@ -0,0 +1,15 @@ +--- +# tasks file for service_checks +- name: Ping peer via SBP + when: object == 'sbp' + ansible.builtin.include_tasks: sbp_checks.yaml + loop: "{{ bgp_obj }}" + loop_control: + loop_var: neighbor + +- name: Check peer status + when: object == 'bgp' + ansible.builtin.include_tasks: bgp_checks.yaml + loop: "{{ bgp_obj }}" + loop_control: + loop_var: neighbor diff --git a/geant/gap_ansible/roles/service_checks/tasks/sbp_checks.yaml b/geant/gap_ansible/roles/service_checks/tasks/sbp_checks.yaml new file mode 100644 index 00000000..68db0093 --- /dev/null +++ b/geant/gap_ansible/roles/service_checks/tasks/sbp_checks.yaml @@ -0,0 +1,18 @@ +--- +- name: Perform ping + 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>//ping count {{ sbp_ping_count }} size {{ sbp_ping_size }} rapid {{ neighbor.peer_address }}</md-cli-input-line> + </md-cli-raw-command> + </global-operations> + display: json + register: out + +- name: Show ping results + when: "'nokiaoper:results' in out.output.['rpc-reply']" + ansible.builtin.debug: + msg: "{{out.output['rpc-reply']['nokiaoper:results']['nokiaoper:md-cli-output-block'].split('\n')}}" diff --git a/geant/gap_ansible/roles/service_checks/vars/main.yml b/geant/gap_ansible/roles/service_checks/vars/main.yml new file mode 100644 index 00000000..d5c11871 --- /dev/null +++ b/geant/gap_ansible/roles/service_checks/vars/main.yml @@ -0,0 +1,4 @@ +--- +# vars file for service_checks + +bgp_obj: "{{ ap.sbp.bgp_session_list }}" -- GitLab From f900689c4c0ff65a3d51495b24158f6118774b10 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurbatov <ak@geant.org> Date: Thu, 5 Dec 2024 18:39:00 +0000 Subject: [PATCH 5/5] l3_core_service: use service_checks --- .../gap_ansible/playbooks/l3_core_service.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/geant/gap_ansible/playbooks/l3_core_service.yaml b/geant/gap_ansible/playbooks/l3_core_service.yaml index 9b154817..d09db643 100644 --- a/geant/gap_ansible/playbooks/l3_core_service.yaml +++ b/geant/gap_ansible/playbooks/l3_core_service.yaml @@ -2,6 +2,23 @@ hosts: all gather_facts: false tasks: + - name: Check SBP + when: verb == 'check' + ansible.builtin.include_role: + name: service_checks + loop: + "{{ subscription.l3_core_service.ap_list }}" + loop_control: + loop_var: ap + + # - name: Check BGP + # # FIX: rewrite + # when: > + # object == 'bgp' + # and + # verb == 'check' + # ansible.builtin.meta: end_play + - name: Generate an ID for this run ansible.builtin.set_fact: opid: "{{ lookup('community.general.random_string', length=18, special=false) }}" -- GitLab