CiscoDevNet / terraform-provider-nxos

Terraform Cisco NX-OS Provider
https://registry.terraform.io/providers/netascode/nxos
Mozilla Public License 2.0
7 stars 10 forks source link

Please add support hsrp for SVI interfaces #174

Open hani010 opened 1 year ago

hani010 commented 1 year ago

Hi, it is possible to add hsrp to provider "nxos_svi_interface" ? We need this SVI interface configuration:

interface Vlan3812
  no shutdown
  vrf member ccsew
  no ip redirects
  ip address 172.25.51.234/29
  no ipv6 redirects
  hsrp bfd
  hsrp version 2
  hsrp 3812 
    preempt delay minimum 60 
    priority 200
    ip 172.25.51.233
jgomezve commented 7 months ago

Hi @hani010

As of now, the provider has a 1:1 mapping between TF resources and objects in the DME Data Model. Therefore it won't be possible to configure HSRP using the nxos_svi_interface because the HSRP configuration requires the creation of multiple additional objects.

I can create dedicated TF resources for the HSRP configuration but I wanted to let you know that you could use the nxos_rest resource to configure those objects that are not covered by the provider. In fact, you could configure everything on the NXOS switch just using the nxos_rest resource. Here an example of the HSRP configuration:


resource "nxos_feature_hsrp" "hsrp" {
  admin_state = "enabled"
}

resource "nxos_rest" "hsrpEntity" {
  dn         = "sys/hsrp"
  class_name = "hsrpEntity"
  content = {
    adminSt = "enabled"
  }
  depends_on = [nxos_feature_hsrp.hsrp]
}

resource "nxos_rest" "hsrpInst" {
  dn         = "${nxos_rest.hsrpEntity.dn}/inst"
  class_name = "hsrpInst"
  content = {
    adminSt = "enabled"
  }
}

resource "nxos_rest" "hsrpIf" {
  dn         = "${nxos_rest.hsrpInst.dn}/if-[vlan3812]"
  class_name = "hsrpIf"
  content = {
    bfd     = "enabled"
    id      = "vlan3812"
    version = "v2"
  }
}

resource "nxos_rest" "hsrpGroup" {
  dn         = "${nxos_rest.hsrpIf.dn}/grp-[3812]-[ipv4]"
  class_name = "hsrpGroup"
  content = {
    af              = "ipv4"
    ctrl            = "preempt"
    fwdLwrThrld     = 0
    fwdUprThrld     = 200
    id              = 3812
    ip              = "172.25.51.233"
    ipObtainMode    = "admin"
    preemptDelayMin = 60
    prio            = 200
  }
}

You can figure out the required objects using the NX-API Sandbox. Information about the dn can be found in the DME Documentation

hani010 commented 7 months ago

Hi Jorge, thank you very much for the information and the solution via Rest Resource. I will try it out in my lab. :-)