mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
New module for BGP configuration management in iosxr (#53121)
* Add iosxr_bgp module Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com> * Remove unused code Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com> * Remove netconf code Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9365c0f468
commit
f615011de3
3
test/integration/targets/iosxr_bgp/defaults/main.yaml
Normal file
3
test/integration/targets/iosxr_bgp/defaults/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
||||
2
test/integration/targets/iosxr_bgp/meta/main.yaml
Normal file
2
test/integration/targets/iosxr_bgp/meta/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_iosxr_tests
|
||||
16
test/integration/targets/iosxr_bgp/tasks/cli.yaml
Normal file
16
test/integration/targets/iosxr_bgp/tasks/cli.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case (connection=network_cli)
|
||||
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
2
test/integration/targets/iosxr_bgp/tasks/main.yaml
Normal file
2
test/integration/targets/iosxr_bgp/tasks/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
226
test/integration/targets/iosxr_bgp/tests/cli/basic.yaml
Normal file
226
test/integration/targets/iosxr_bgp/tests/cli/basic.yaml
Normal file
@@ -0,0 +1,226 @@
|
||||
---
|
||||
- debug: msg="START iosxr cli/iosxr_bgp.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: Clear existing BGP config
|
||||
iosxr_bgp:
|
||||
operation: delete
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Configure BGP with AS 64496 and a router-id
|
||||
iosxr_bgp: &config
|
||||
operation: merge
|
||||
config:
|
||||
bgp_as: 64496
|
||||
router_id: 192.0.2.2
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- "'router bgp 64496' in result.commands"
|
||||
- "'bgp router-id 192.0.2.2' in result.commands"
|
||||
|
||||
- name: Configure BGP with AS 64496 and a router-id (idempotent)
|
||||
iosxr_bgp: *config
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: Configure BGP neighbors
|
||||
iosxr_bgp: &nbr
|
||||
operation: merge
|
||||
config:
|
||||
bgp_as: 64496
|
||||
neighbors:
|
||||
- neighbor: 192.0.2.10
|
||||
remote_as: 64496
|
||||
description: IBGP_NBR_1
|
||||
advertisement_interval: 120
|
||||
timers:
|
||||
keepalive: 300
|
||||
holdtime: 360
|
||||
|
||||
- neighbor: 192.0.2.15
|
||||
remote_as: 64496
|
||||
description: IBGP_NBR_2
|
||||
tcp_mss: 1500
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- "'router bgp 64496' in result.commands"
|
||||
- "'neighbor 192.0.2.10' in result.commands"
|
||||
- "'remote-as 64496' in result.commands"
|
||||
- "'description IBGP_NBR_1' in result.commands"
|
||||
- "'timers 300 360' in result.commands"
|
||||
- "'advertisement-interval 120' in result.commands"
|
||||
- "'neighbor 192.0.2.15' in result.commands"
|
||||
- "'remote-as 64496' in result.commands"
|
||||
- "'description IBGP_NBR_2' in result.commands"
|
||||
- "'tcp mss 1500' in result.commands"
|
||||
|
||||
- name: Configure BGP neighbors (idempotent)
|
||||
iosxr_bgp: *nbr
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: Configure BGP neighbors with operation replace
|
||||
iosxr_bgp: &nbr_rplc
|
||||
operation: replace
|
||||
config:
|
||||
bgp_as: 64496
|
||||
neighbors:
|
||||
- neighbor: 192.0.2.15
|
||||
remote_as: 64496
|
||||
description: IBGP_NBR_2
|
||||
tcp_mss: 1500
|
||||
|
||||
- neighbor: 203.0.113.10
|
||||
remote_as: 64511
|
||||
description: EBGP_NBR_1
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- "'neighbor 203.0.113.10' in result.commands"
|
||||
- "'remote-as 64511' in result.commands"
|
||||
- "'description EBGP_NBR_1' in result.commands"
|
||||
- "'no neighbor 192.0.2.10' in result.commands"
|
||||
|
||||
- name: Configure BGP neighbors with operation replace (idempotent)
|
||||
iosxr_bgp: *nbr_rplc
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: Configure networks under address family
|
||||
iosxr_bgp: &af_net
|
||||
operation: merge
|
||||
config:
|
||||
bgp_as: 64496
|
||||
address_family:
|
||||
- afi: ipv4
|
||||
networks:
|
||||
- prefix: 198.51.100.48
|
||||
masklen: 28
|
||||
route_map: RMAP_1
|
||||
|
||||
- prefix: 192.0.2.64
|
||||
masklen: 27
|
||||
|
||||
- prefix: 203.0.113.160
|
||||
masklen: 27
|
||||
|
||||
- afi: ipv4
|
||||
safi: multicast
|
||||
networks:
|
||||
- prefix: 198.51.100.64
|
||||
masklen: 28
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- "'router bgp 64496' in result.commands"
|
||||
- "'address-family ipv4 unicast' in result.commands"
|
||||
- "'network 198.51.100.48/28 route-policy RMAP_1' in result.commands"
|
||||
- "'network 192.0.2.64/27' in result.commands"
|
||||
- "'network 203.0.113.160/27' in result.commands"
|
||||
- "'address-family ipv4 multicast' in result.commands"
|
||||
- "'network 198.51.100.64/28' in result.commands"
|
||||
|
||||
- name: Configure networks under address family (idempotent)
|
||||
iosxr_bgp: *af_net
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: Configure networks under address family with operation replace
|
||||
iosxr_bgp: &af_net_rplc
|
||||
operation: replace
|
||||
config:
|
||||
bgp_as: 64496
|
||||
address_family:
|
||||
- afi: ipv4
|
||||
safi: unicast
|
||||
networks:
|
||||
- prefix: 198.51.100.80
|
||||
masklen: 28
|
||||
|
||||
- prefix: 192.0.2.64
|
||||
masklen: 27
|
||||
|
||||
- prefix: 203.0.113.192
|
||||
masklen: 27
|
||||
|
||||
- afi: ipv4
|
||||
safi: multicast
|
||||
networks:
|
||||
- prefix: 198.51.100.64
|
||||
masklen: 28
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"router bgp 64496" in result.commands'
|
||||
- '"address-family ipv4 unicast" in result.commands'
|
||||
- '"network 198.51.100.80/28" in result.commands'
|
||||
- '"network 203.0.113.192/27" in result.commands'
|
||||
- '"no network 198.51.100.48/28" in result.commands'
|
||||
- '"no network 203.0.113.160/27" in result.commands'
|
||||
|
||||
- name: Configure networks under address family with operation replace (idempotent)
|
||||
iosxr_bgp: *af_net_rplc
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: Override all the exisiting BGP config
|
||||
iosxr_bgp:
|
||||
operation: override
|
||||
config:
|
||||
bgp_as: 64497
|
||||
router_id: 192.0.2.10
|
||||
log_neighbor_changes: True
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- "'router bgp 64497' in result.commands"
|
||||
- "'bgp router-id 192.0.2.10' in result.commands"
|
||||
- "'bgp log neighbor changes detail' in result.commands"
|
||||
|
||||
- name: Teardown
|
||||
iosxr_bgp: &rm
|
||||
operation: delete
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- "'no router bgp 64497' in result.commands"
|
||||
|
||||
- name: Teardown again (idempotent)
|
||||
iosxr_bgp: *rm
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- debug: msg="END iosxr cli/iosxr_bgp.yaml on connection={{ ansible_connection }}"
|
||||
Reference in New Issue
Block a user