Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
skip_list:
- var-naming[no-role-prefix] # this rule error out correct vars names for network validated content.
- var-naming[no-role-prefix] # this rule error out correct vars names for network validated content.
6 changes: 3 additions & 3 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
authors:
- Rohit Thakur (rohitthakur2590)
dependencies:
"ansible.netcommon": ">=6.0.0"
"ansible.utils": ">=3.0.0"
"ansible.scm": ">=2.0.0"
ansible.netcommon: ">=6.0.0"
ansible.utils: ">=3.0.0"
ansible.scm: ">=2.0.0"
license_file: LICENSE
name: bgp
description: Ansible Network BGP enables users to manage the BGP resources independently of platforms and perform BGP health checks.
Expand Down
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/configure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
ansible.builtin.include_role:
name: network.base.resource_manager
vars:
operation: 'configure'
operation: configure
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
ansible.builtin.include_role:
name: network.base.resource_manager
vars:
operation: 'deploy'
operation: deploy
resources: "{{ bgp_resources }}"
4 changes: 2 additions & 2 deletions roles/run/tasks/includes/detect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
ansible.builtin.include_role:
name: network.base.resource_manager
vars:
operation: 'detect'
state: 'replaced'
operation: detect
state: replaced
resources: "{{ bgp_resources }}"
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/gather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
ansible.builtin.include_role:
name: network.base.resource_manager
vars:
operation: 'gather'
operation: gather
resources: "{{ bgp_resources }}"
4 changes: 2 additions & 2 deletions roles/run/tasks/includes/health_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

- name: Set health checks fact
ansible.builtin.set_fact:
health_checks: "{{ bgp_health | network.bgp.health_check_view(operation) }}"
health_checks: "{{ bgp_health | network.bgp.health_check_view(operation) }}"

- name: BGP health checks
ansible.builtin.debug:
var: health_checks
var: health_checks
failed_when: "'unsuccessful' == health_checks.status"
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/health_checks/eos.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Parse bgp summary
ansible.utils.cli_parse:
command: "show ip bgp summary"
command: show ip bgp summary
parser:
name: ansible.netcommon.content_templates
set_fact: bgp_health
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/health_checks/ios.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Parse bgp summary
ansible.utils.cli_parse:
command: "show bgp summary"
command: show bgp summary
parser:
name: ansible.netcommon.content_templates
set_fact: bgp_health
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/health_checks/iosxr.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Parse bgp summary
ansible.utils.cli_parse:
command: "show bgp summary"
command: show bgp summary
parser:
name: ansible.netcommon.content_templates
set_fact: bgp_health
3 changes: 1 addition & 2 deletions roles/run/tasks/includes/health_checks/junos.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
- name: Parse bgp summary
ansible.utils.cli_parse:
command: "show bgp summary"
command: show bgp summary
parser:
name: ansible.netcommon.content_templates
set_fact: bgp_health


- name: Show Summary facts
ansible.builtin.debug:
msg: "{{ bgp_health }}"
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/health_checks/nxos.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Parse bgp summary
ansible.utils.cli_parse:
command: "show ip bgp summary"
command: show ip bgp summary
parser:
name: ansible.netcommon.content_templates
set_fact: bgp_health
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/health_checks/vyos.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Parse bgp summary
ansible.utils.cli_parse:
command: "show ip bgp summary"
command: show ip bgp summary
parser:
name: ansible.netcommon.content_templates
set_fact: bgp_health
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
ansible.builtin.include_role:
name: network.base.resource_manager
vars:
operation: 'list'
operation: list
2 changes: 1 addition & 1 deletion roles/run/tasks/includes/persist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
ansible.builtin.include_role:
name: network.base.resource_manager
vars:
operation: 'persist'
operation: persist
resources: "{{ bgp_resources }}"
ignore_empty: "{{ persist_empty | default(true) }}"
4 changes: 2 additions & 2 deletions roles/run/tasks/includes/remediate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
ansible.builtin.include_role:
name: network.base.resource_manager
vars:
operation: 'remediate'
state: 'replaced'
operation: remediate
state: replaced
resources: "{{ bgp_resources }}"
10 changes: 5 additions & 5 deletions roles/run/tasks/includes/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
- name: Set resources
ansible.builtin.set_fact:
bgp_resources:
- 'bgp_global'
- 'bgp_address_family'
- 'bgp_neighbor_address_family'
- bgp_global
- bgp_address_family
- bgp_neighbor_address_family
when: ansible_network_os == 'cisco.nxos.nxos'

- name: Set resources
ansible.builtin.set_fact:
bgp_resources:
- 'bgp_global'
- 'bgp_address_family'
- bgp_global
- bgp_address_family
when: ansible_network_os != 'cisco.nxos.nxos'
21 changes: 10 additions & 11 deletions tests/bgp/roles/tests/tasks/health_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,44 @@
msg_rcvd: 73271
msg_sent: 73233
output_queue: 0
peer: "12.0.0.1"
peer: 12.0.0.1
peer_as: 500
peer_state: 1
uptime: "6w4d"
uptime: 6w4d
version: 4

- bgp_table_version: 1
input_queue: 0
msg_rcvd: 0
msg_sent: 0
output_queue: 0
peer: "23.0.0.1"
peer: 23.0.0.1
peer_as: 500
peer_state: "Idle"
uptime: "never"
peer_state: Idle
uptime: never
version: 4
path:
memory_usage: 288
total_entries: 2

route_table_version: 3
router_id: "22.0.0.1"
router_id: 22.0.0.1

- name: Vars
ansible.builtin.set_fact:
tests_item:
name: "health_check"
name: health_check
vars:
checks:
- name: "all_neighbors_up"
- name: "all_neighbors_down"
- name: "min_neighbors_up"
- name: all_neighbors_up
- name: all_neighbors_down
- name: min_neighbors_up
min_count: 1

- name: Set BGP health facts
ansible.builtin.set_fact:
tests_health_checks: "{{ bgp_health | ansible.utils.health_check_view(tests_item) }}"


- name: Check for accurate facts
ansible.builtin.assert:
that: "{{ tests_health_checks == tests_expected_health_checks }}"
2 changes: 0 additions & 2 deletions tests/integration/targets/bgp_deploy/includes/assertions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
- name: Task name
ansible.builtin.stat:
path: "{{ test_data_store['local'] }}/host_vars/{{ inventory_hostname }}/{{ filename }}.yaml"
register: result

- name: Assert that gather result
ansible.builtin.assert:
that:
- result.stat.exists == true
2 changes: 1 addition & 1 deletion tests/integration/targets/bgp_deploy/tasks/_cleanup.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Clean persist operation output
ansible.builtin.file:
path: "~/test_backup"
path: ~/test_backup
state: absent
58 changes: 53 additions & 5 deletions tests/integration/targets/bgp_deploy/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,71 @@
---
- name: Debug
ansible.builtin.debug:
msg: "START network.bgp deploy opeartion integration tests on connection={{ ansible_connection }}"
msg: START network.bgp deploy opeartion integration tests on connection={{ ansible_connection }}

- name: Cleanup, Read and Deploy
block:
- name: Reset configuration
ansible.builtin.include_tasks: _cleanup.yaml

- name: Clean persist operation output

block:
- name: Reset configuration
ansible.builtin.include_tasks: _cleanup.yaml

- name: Set data data_store
ansible.builtin.set_fact:
test_data_store:
local: ~/test_backup

- name: Set resources
ansible.builtin.set_fact:
test_resources:
- bgp_global
- bgp_address_family

- name: Run network.bgp validated content with deploy operation
ansible.builtin.include_role:
name: network.bgp.run
vars:
operations:
- name: persist
data_store: "{{ test_data_store }}"

- name: Run network.bgp validated content with deploy operation
ansible.builtin.include_role:
name: network.bgp.run
vars:
operations:
- name: deploy
data_store: "{{ test_data_store }}"
register: bgp_result

- name: Assert that gresult
ansible.builtin.assert:
that:
- bgp_result.changed == false

- name: Reset configuration
ansible.builtin.include_tasks: _cleanup.yaml

- name: Clean persist operation output

block:
- name: Reset configuration
ansible.builtin.include_tasks: _cleanup.yaml

- name: Set data data_store
ansible.builtin.set_fact:
test_data_store:
local: "~/test_backup"
local: ~/test_backup

- name: Set resources
ansible.builtin.set_fact:
test_resources:
- 'bgp_global'
- 'bgp_address_family'
- bgp_global
- bgp_address_family

- name: Run network.bgp validated content with deploy operation
ansible.builtin.include_role:
Expand Down Expand Up @@ -47,4 +95,4 @@

- name: Debug
ansible.builtin.debug:
msg: "END network.bgp deploy operation integration tests on connection={{ ansible_connection }}"
msg: END network.bgp deploy operation integration tests on connection={{ ansible_connection }}
2 changes: 0 additions & 2 deletions tests/integration/targets/bgp_detect/includes/assertions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
- name: Task name
ansible.builtin.stat:
path: "{{ test_data_store['local'] }}/host_vars/{{ inventory_hostname }}/{{ filename }}.yaml"
register: result

- name: Assert that gather result
ansible.builtin.assert:
that:
- result.stat.exists == true
2 changes: 1 addition & 1 deletion tests/integration/targets/bgp_detect/tasks/_cleanup.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Clean persist operation output
ansible.builtin.file:
path: "~/test_backup"
path: ~/test_backup
state: absent
Loading