CiscoDevNet / terraform-provider-iosxr

Terraform Cisco IOS-XR Provider
https://registry.terraform.io/providers/CiscoDevNet/iosxr
Mozilla Public License 2.0
6 stars 9 forks source link

Bug: iosxr_interface resource do not support changing ip address on subinterface #244

Closed edudppaz closed 2 weeks ago

edudppaz commented 7 months ago

After the iosxr_interface has configured a subinterface, changing the ip address on the same interface throws an error:

Plan result:

Terraform will perform the following actions:

  # iosxr_interface.sda_link_subif_fw["OSL-fw-fn02"] will be updated in-place
  ~ resource "iosxr_interface" "sda_link_subif_fw" {
        id                          = "Cisco-IOS-XR-um-interface-cfg:/interfaces/interface[interface-name=GigabitEthernet0/0/0/6.3130]"
      ~ ipv4_address                = "192.0.3.19" -> "192.0.3.35"
        # (8 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Apply:

iosxr_interface.sda_link_subif_fw["OSL-fw-fn02"]: Still modifying... [id=Cisco-IOS-XR-um-interface-cfg:/interfac...face-name=GigabitEthernet0/0/0/6.3130], 10s elapsed]
╷
│ Error: Client Error
│ 
│   with iosxr_interface.sda_link_subif_fw["OSL-fw-fn02"],
│   on main.tf line 292, in resource "iosxr_interface" "sda_link_subif_fw":
│  292: resource "iosxr_interface" "sda_link_subif_fw" {
│ 
│ Set request failed, got error: rpc error: code = Internal desc = gNMI
│ commit-request: operation-failed: Subinterface or Layer 2 configuration
│ conflicts with existing configuration, or configuration in this commit:
│ Please refer to configuration documentation for further assistance:
│ Cisco-IOS-XR-um-interface-cfg:interfaces/interface[interface-name =
│ 'GigabitEthernet0/0/0/6.3130']/interface-name

Manually using "taint" to destroy the resource before re-creating, or running a terraform destroy on that specific resource before a new plan/apply, correctly configures the new ip address (after removing the interface and re-applying).

This is a basic change that should be supported in the resource.

danischm commented 7 months ago

I quickly tested it with this config and changing the IP of the subinterface, which worked for me..

resource "iosxr_interface" "main" {
  interface_name = "GigabitEthernet0/0/0/3"
  ipv4_address   = "1.1.1.3"
  ipv4_netmask   = "255.255.255.0"
}

resource "iosxr_interface" "sub" {
  interface_name              = "GigabitEthernet0/0/0/3.200"
  encapsulation_dot1q_vlan_id = 200
  ipv4_address                = "2.1.1.4"
  ipv4_netmask                = "255.255.255.0"
}

Could you maybe try the same and see if that works for you?

edudppaz commented 7 months ago

Hi @danischm im currently not configuring anything on the main interface, only touching the subinterface configuration. But i will try doing "something" on the main interface (a description, for example) and try again.

edudppaz commented 2 weeks ago

This seems to work when we also configured the physical interface and then the subinterface.