Dear,
We have an issue regarding the iosxe_route_map / match_source_protocol_bgp behaviour statement.
Changes and Deletions do not seem to be handled properly.
Can you please look at this?
IOSXE TF Provider version: self-compiled 0.4.1 unreleased (date Tue Sept 19 2023)
IOS version: Cisco IOS XE Software, Version 17.11.01a
Below is a step-by-step example on howto reproduce and some debug information.
start clean
ROUTER8001#show route-map GITHUB
route-map GITHUB not found
resource source config for creation
resource "iosxe_route_map" "github" {
provider = iosxe.router8001
name = "GITHUB"
entries = [
{
seq = 10
operation = "permit"
description = "Entry 10"
continue = false
match_source_protocol_bgp = ["65001"]
}
]
}
Terraform apply output for creation (works fine)
Terraform will perform the following actions:
# iosxe_route_map.github will be created
+ resource "iosxe_route_map" "github" {
+ entries = [
+ {
+ continue = false
+ description = "Entry 10"
+ match_source_protocol_bgp = [
+ "65001",
]
+ operation = "permit"
+ seq = 10
},
]
+ id = (known after apply)
+ name = "GITHUB"
}
Plan: 1 to add, 0 to change, 0 to destroy.
iosxe_route_map.github: Creating...
iosxe_route_map.github: Creation complete after 1s [id=Cisco-IOS-XE-native:native/route-map=GITHUB]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
running config after creation (looks ok)
ROUTER8001#show route-map GITHUB
route-map GITHUB, permit, sequence 10
Match clauses:
source-protocol bgp 65001
Set clauses:
Policy routing matches: 0 packets, 0 bytes
ROUTER8001#
resource source config modification #1: replace 65001 with 65002
resource "iosxe_route_map" "github" {
provider = iosxe.router8001
name = "GITHUB"
entries = [
{
seq = 10
operation = "permit"
description = "Entry 10"
continue = false
match_source_protocol_bgp = ["65002"]
}
]
}
Terraform apply output suggests correct behaviour
Terraform will perform the following actions:
# iosxe_route_map.github will be updated in-place
~ resource "iosxe_route_map" "github" {
~ entries = [
~ {
~ match_source_protocol_bgp = [
- "65001",
+ "65002",
]
# (4 unchanged attributes hidden)
},
]
id = "Cisco-IOS-XE-native:native/route-map=GITHUB"
name = "GITHUB"
}
Plan: 0 to add, 1 to change, 0 to destroy.
iosxe_route_map.github: Modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB]
iosxe_route_map.github: Modifications complete after 0s [id=Cisco-IOS-XE-native:native/route-map=GITHUB]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
running config after modifcation is unexpected: 65002 has been added instead of replaced
ROUTER8001#show route-map GITHUB
route-map GITHUB, permit, sequence 10
Match clauses:
source-protocol bgp 65001 bgp 65002
Set clauses:
Policy routing matches: 0 packets, 0 bytes
ROUTER8001#
running config / partial JSON after modifcation: 65002 has been added instead of replaced
"route-map": [
{
"name": "GITHUB",
"Cisco-IOS-XE-route-map:route-map-without-order-seq": [
{
"seq_no": 10,
"operation": "permit",
"descriptions": [
{
"description-leaf": "Entry 10"
}
],
"match": {
"source-protocol": {
"bgp": [65001, 65002]
}
}
}
]
},
resource source config modification #2: remove the complete statement
resource "iosxe_route_map" "github" {
provider = iosxe.router8001
name = "GITHUB"
entries = [
{
seq = 10
operation = "permit"
description = "Entry 10"
continue = false
# match_source_protocol_bgp = ["65002"]
}
]
}
Terraform apply output suggests correct behaviour ... and fails
Terraform will perform the following actions:
# iosxe_route_map.github will be updated in-place
~ resource "iosxe_route_map" "github" {
~ entries = [
~ {
- match_source_protocol_bgp = [
- "65001",
- "65002",
] -> null
# (4 unchanged attributes hidden)
},
]
id = "Cisco-IOS-XE-native:native/route-map=GITHUB"
name = "GITHUB"
}
Plan: 0 to add, 1 to change, 0 to destroy.
iosxe_route_map.github: Modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB]
iosxe_route_map.github: Still modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB, 10s elapsed]
iosxe_route_map.github: Still modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB, 20s elapsed]
╷
│ Error: Client Error
│
│ with iosxe_route_map.github,
│ on cisco8001.tf line 237, in resource "iosxe_route_map" "github":
│ 237: resource "iosxe_route_map" "github" {
│
│ Failed to delete object, got error: HTTP Request failed: StatusCode 400, RESTCONF errors {Error:[{ErrorType:application ErrorTag:invalid-value ErrorAppTag: ErrorPath:
│ ErrorMessage:inconsistent value: Device refused one or more commands ErrorInfo:}]} {PatchId: GlobalStatus:{Ok:false Errors:{Error:[]}} EditStatus:{Edit:[]}
│ Errors:{Error:[]}}
running config after failed attempt
ROUTER8001#show route-map GITHUB
route-map GITHUB, permit, sequence 10
Match clauses:
source-protocol bgp 65002 bgp 65001
Set clauses:
Policy routing matches: 0 packets, 0 bytes