Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface VRF change does not reapply HSRP config #251

Open
mobig opened this issue Jul 17, 2024 · 1 comment
Open

Interface VRF change does not reapply HSRP config #251

mobig opened this issue Jul 17, 2024 · 1 comment

Comments

@mobig
Copy link

mobig commented Jul 17, 2024

It seems that when you change the VRF on an interface, the provider is smart enough to detect that the interface IP needs to be reapplied as NXOS removes the IP (stealthy). However, this does not seem to be the case with HSRP config. I request the same functionality for HSRP config so it persists after an interface VRF assignment change.

@jgomezve
Copy link
Collaborator

Hi @mobig

In the example you mentioned, after modifying the VRF name, Terraform is smart enough to re-create the IP address resource (nxos_ipv4_interface_address) because the vrf attribute is marked internally as RequiresReplace().

Unfortunately, the same approach cannot be taken for the HSRP resources, as those resources do not have any relationship with the VRF objects inside the DME tree. However, you could leverage the attribute replace_triggered_by inside the meta-argument lifecycle, which as the name implies forces a resource to be re-created if a specific attribute of another resource changes. Here is a basic example:

resource "nxos_rest" "hsrpIf" {
  dn         = "${nxos_rest.hsrpInst.id}/if-[eth1/11]"
  class_name = "hsrpIf"
  content = {
    id      = "eth1/11"
    version = "v2"
  }
    lifecycle {
    replace_triggered_by = [
      nxos_ipv4_interface_address.example.id
    ]
  }
}

I have created a full Terraform plan with you use-case here https://gist.github.com/jgomezve/8db59dfc52b62bd4adf6d08a0fb3c573

In this Terraform plan I am forcing the creation the MOs hsrpIf and hsrpGroup if the IP address of an interface changes

Let me know if this works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants