Skip to content

cisco.ios.ios_bgp_address_family doesn't remove configuration as expected in state: Replaced! #1253

@sunshinegorgon7

Description

@sunshinegorgon7
SUMMARY

I have a neighbor with a route map applied that does ASPATH PREPEND, and if I deleted the route map & let's say add it to another neighbor, then I expect that to happen, as in route map to be removed from Neighbor A & applied to Neighbor B

ISSUE TYPE
  • Bug Report
COMPONENT NAME

[cisco.ios.ios_bgp_address_family]

ANSIBLE VERSION
ansible [core 2.16.14]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ansible/.local/lib/python3.11/site-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ansible/.local/bin/ansible
  python version = 3.11.11 (main, Dec  9 2024, 15:32:27) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/usr/bin/python3.11)
  jinja version = 3.1.6
  libyaml = True

COLLECTION VERSION
# /home/ansible/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.ios  9.1.2

# /home/ansible/.local/lib/python3.11/site-packages/ansible_collections
Collection Version
---------- -------
cisco.ios  9.1.1

CONFIGURATION
ACTION_WARNINGS(/etc/ansible/ansible.cfg) = False
CALLBACKS_ENABLED(/etc/ansible/ansible.cfg) = ['profile_tasks']
CONFIG_FILE() = /etc/ansible/ansible.cfg
DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 30
DEFAULT_LOCAL_TMP(/etc/ansible/ansible.cfg) = /tmp/.ansible/tmp/ansible-loca>
DEFAULT_POLL_INTERVAL(/etc/ansible/ansible.cfg) = 15
DISPLAY_SKIPPED_HOSTS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/etc/ansible/ansible.cfg) = auto_silent
OS / ENVIRONMENT

ISR 4331
Cisco IOS XE Software, Version 17.03.04a

STEPS TO REPRODUCE

apply this bgp configuration to a router

cisco.ios.ios_route_maps:
config:
	- route_map: AS-PATH-PREPEND
	entries:
	  - action: permit
		sequence: 10
		set:
		  as_path:
			prepend:
			  as_number:
				- '1111'
				- '1111'

cisco.ios.ios_bgp_global:
  config:
	as_number: '1111'
	bgp:
	default:
	  ipv4_unicast: true
	  route_target:
		filter: true
	log_neighbor_changes: true
	router_id:
	  address: 9.9.9.9
	neighbors:
	- neighbor_address: 2.2.2.2
	  description: Datamena-1Gbps
	  remote_as: '11115'
	  timers:
		holdtime: 60
		interval: 20
	  fall_over:
		bfd:
		  set: true
	- neighbor_address: 1.1.1.1
	  remote_as: '22221'
	  timers:
		holdtime: 60
		interval: 20

cisco.ios.ios_bgp_address_family:
  config:
	as_number: '1111'
	address_family:
	- afi: ipv4
	  maximum_paths:
		paths: 2
	  neighbors:
		- activate: true
		  neighbor_address: 1.1.1.1
		  weight: 200

		- activate: true
		  neighbor_address: 2.2.2.2
		  route_maps:
			- name: AS-PATH-PREPEND
			  out: true
		  weight: 100
	  networks:
		- address: 5.5.5.0
		  mask: 255.255.255.0

and then change it to this config & apply it
where I basically swap (hence the config) for the neighbor address under the address_family

cisco.ios.ios_bgp_global:
  config:
	as_number: '1111'
	bgp:
	default:
	  ipv4_unicast: true
	  route_target:
		filter: true
	log_neighbor_changes: true
	router_id:
	  address: 9.9.9.9
	neighbors:
	- neighbor_address: 2.2.2.2
	  description: Datamena-1Gbps
	  remote_as: '11115'
	  timers:
		holdtime: 60
		interval: 20
	  fall_over:
		bfd:
		  set: true
	- neighbor_address: 1.1.1.1
	  remote_as: '22221'
	  timers:
		holdtime: 60
		interval: 20

cisco.ios.ios_bgp_address_family:
  config:
	as_number: '1111'
	address_family:
	- afi: ipv4
	  maximum_paths:
		paths: 2
	  neighbors:
		- activate: true
		  neighbor_address: 2.2.2.2
		  weight: 200

		- activate: true
		  neighbor_address: 1.1.1.1
		  route_maps:
			- name: AS-PATH-PREPEND
			  out: true
		  weight: 100
	  networks:
		- address: 5.5.5.0
		  mask: 255.255.255.0
EXPECTED RESULTS

router bgp 1111
bgp router-id 9.9.9.9
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 35819
neighbor 2.2.2.2 remote-as 48237
!
address-family ipv4
network 5.5.5.0 mask 255.255.255.0
neighbor 2.2.2.2 activate
neighbor 2.2.2.2 weight 100
neighbor 1.1.1.1 activate
neighbor 1.1.1.1 weight 200
neighbor 1.1.1.1 route-map AS-PATH-PREPEND out

ACTUAL RESULTS

The playbook correctly swapped the weights & apply the route-map to the neighbor i wanted but DID NOT remove it from the neighbor that had it deleted under it's address family config, and so you can see below the output of my router shows both neighbours have the routemaps even tho only one neighbour had the routemap applied and in state replaced i expected to have it removed from neighbor 2.2.2.2

router bgp 1111
 bgp router-id 9.9.9.9
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 35819
 neighbor 2.2.2.2 remote-as 48237
 !
 address-family ipv4
  network 5.5.5.0 mask 255.255.255.0
  neighbor 1.1.1.1 activate
  neighbor 1.1.1.1 weight 200
  neighbor 1.1.1.1 route-map AS-PATH-PREPEND out
  neighbor 2.2.2.2 activate
  neighbor 2.2.2.2 weight 100
  neighbor 2.2.2.2 route-map AS-PATH-PREPEND out

This is the relevant part of the playbook output with verbosity enabled and it shows that in the before it detected a route-map

                                "route_maps": [
                                    {
                                        "in": null,
                                        "name": "AS-PATH-PREPEND",
                                        "out": true
                                    }
                                ],

and in the after it's null

                                "route_map": null,
                                "route_maps": null,

yet it didn't remove it!

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions