Skip to content
Snippets Groups Projects
Commit 267b6084 authored by ak@geant.org's avatar ak@geant.org
Browse files

BGP pre-post checks: changes proposal

parent bf41faae
No related branches found
No related tags found
No related merge requests found
---
###############################################################################################################
# The playbook does the following:
#
# - Loads variables from pre and post check results
# - Prints all the pre or post check BGP statistics that were retreived
# - Runs a number of assertions upon these metrics and prints weather a metric has been a 'PASS' or 'FAIL':
# - Checks if bgp_state (peer-state) is 'Established' = PASS
# - Checks if bfd_operstate (bfd-operational-state) is 'UP' = PASS
# - If there is a FAIL, the playbook stops
#
###############################################################################################################
- name: Load variables from pre and post check results
ansible.builtin.include_vars:
dir: vars
files_matching: "{{ check_id }}.yaml"
- name: TEST Print PRE interface statistics
ansible.builtin.debug:
var: pre_check
when: verb == 'pre_check'
- name: TEST Print POST interface statistics
ansible.builtin.debug:
var: post_check
when: verb == 'post_check'
# SESSION_UP: The BGP session must be up (both IPv4 and IPv6)
- name: Get bgp state
ansible.builtin.assert:
that:
- "{{ verb }}.{{ check_id }}.bgp_state == 'Established'"
fail_msg: "FAIL: bgp isn't Established"
success_msg: "PASS: bgp state is Established"
failed_when: false
# BFD: If BFD is configured, it should be UP
- name: Get bfd state
ansible.builtin.assert:
that:
- "{{ verb }}.{{ check_id }}.bfd_operstate == 'Up'"
fail_msg: "FAIL: bfd isn't Up"
success_msg: "PASS: bfd state is Up"
failed_when: false
...@@ -27,25 +27,6 @@ ...@@ -27,25 +27,6 @@
var: post_check var: post_check
when: verb == 'post_check' when: verb == 'post_check'
# SESSION_UP: The BGP session must be up (both IPv4 and IPv6)
- name: Get bgp state
ansible.builtin.assert:
that:
- "{{ verb }}.{{ check_id }}.bgp_state == 'Established'"
fail_msg: "FAIL: bgp isn't Established"
success_msg: "PASS: bgp state is Established"
failed_when: false
# BFD: If BFD is configured, it should be UP
- name: Get bfd state
ansible.builtin.assert:
that:
- "{{ verb }}.{{ check_id }}.bfd_operstate == 'Up'"
fail_msg: "FAIL: bfd isn't Up"
success_msg: "PASS: bfd state is Up"
failed_when: false
# NLRIs: The NLRIs exchanged must be the same # NLRIs: The NLRIs exchanged must be the same
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
- name: Get output file information - name: Get output file information
ansible.builtin.stat: ansible.builtin.stat:
path: roles/bgp_checks/vars/{{ check_id }}.yaml path: "{{ results_dir }}{{ check_id }}.yaml"
register: file_status register: file_status
- name: Creating a file with results content - name: Creating a file with results content
...@@ -46,14 +46,14 @@ ...@@ -46,14 +46,14 @@
{{ 'bgp_rec_active:' }} {{ bgp_rec_active }} {{ 'bgp_rec_active:' }} {{ bgp_rec_active }}
{{ 'bgp_rec_holddown:' }} {{ bgp_rec_holddown }} {{ 'bgp_rec_holddown:' }} {{ bgp_rec_holddown }}
{{ 'bgp_rec_hidden:' }} {{ bgp_rec_hidden }} {{ 'bgp_rec_hidden:' }} {{ bgp_rec_hidden }}
dest: "roles/bgp_checks/vars/{{ check_id }}.yaml" dest: "{{ results_dir }}{{ check_id }}.yaml"
mode: '0660' mode: '0660'
when: when:
- not file_status.stat.exists - not file_status.stat.exists
- name: Add post_check parameters to yaml - name: Add post_check parameters to yaml
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
path: "roles/bgp_checks/vars/{{ check_id }}.yaml" path: "{{ results_dir }}{{ check_id }}.yaml"
marker: "# {mark} -------------- POST CHECKS ----------------------------- #" marker: "# {mark} -------------- POST CHECKS ----------------------------- #"
block: | block: |
{{ verb + ':' }} {{ verb + ':' }}
......
...@@ -65,6 +65,11 @@ ...@@ -65,6 +65,11 @@
- verb in verbs - verb in verbs
- name: Include task - name: Include task
ansible.builtin.include_tasks: check.yaml ansible.builtin.include_tasks: check_bgp_status.yaml
when: when:
- verb in verbs - verb in verbs
- name: Include task
ansible.builtin.include_tasks: compare_pre_post.yaml
when:
- verb == 'post_check'
--- ---
# vars file for L3-BGP-based-checks # vars file for L3-BGP-based-checks
results_dir: "/var/tmp/"
max_adv_routes_diff: 10
max_rec_routes_diff: 10
dryrun: "True" dryrun: "True"
verbs: verbs:
- "pre_check" - "pre_check"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment