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

Cannot enable: false on netbox_device_interface #448

Closed
bebehei opened this issue Aug 3, 2023 · 2 comments · Fixed by #449
Closed

Cannot enable: false on netbox_device_interface #448

bebehei opened this issue Aug 3, 2023 · 2 comments · Fixed by #449

Comments

@bebehei
Copy link
Contributor

bebehei commented Aug 3, 2023

Background: I'm currently reading Junipers via ssh <juniper> "show <whatever> | display json" and render the configuration to a terraform JSON. I'm using terraform to remember the state and delete objects in Netbox, which had been deconfigured in Real World.

Some of these interfaces are deactivated, so I deactivate them in the config, too. See here the excerpt from one disabled interface:

[benedikt.heine] $ jq '.resource."netbox_device_interface"."nue1-tor-1_xe-0_0_23"' < crawler.tf.json                                           
{
  "description": "redacted",
  "device_id": "${netbox_device.nue1-tor-1.id}",
  "enabled": false,
  "mac_address": "redacted",
  "mtu": 1514,
  "name": "xe-0/0/23",
  "speed": 10000000,
  "type": "10gbase-x-sfpp"
}
[benedikt.heine] $ 

As you can see, the enabled property is required to get changed after a terraform apply. The problem, it persists:

  # netbox_device_interface.nue1-tor-1_xe-0_0_23 will be updated in-place
  ~ resource "netbox_device_interface" "nue1-tor-1_xe-0_0_23" {
      ~ enabled      = true -> false
        id           = "4156"
        name         = "xe-0/0/23"
        tags         = []
        # (10 unchanged attributes hidden)
    }

After changing manually the attribute in the Netbox, subsequent terraform apply will notice the manual change and hence will do nothing on the resource.

  • Netbox Version: e8de4824a8ce (v3.5.6)
  • Netbox Terraform Provider Versions: 3.2.1 (also tested with self-built provider from current master)

Is this an incompatibility introduced by Netbox 3.5 or is this happening already in 3.4?

@fbreckle
Copy link
Collaborator

fbreckle commented Aug 4, 2023

Yeah, this is a common problem with optional attributes. This has nothing to do with 3.5 but with the way the go-netbox client handles zero attributes.
I verified the bug in b47e36c and also created a general ticket for this type of issue in netbox-community/go-netbox#107
Note that in the meantime, I forked go-netbox so the todo here is just fixing it there.

@bebehei
Copy link
Contributor Author

bebehei commented Aug 5, 2023

@fbreckle Thank you very much!

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

Successfully merging a pull request may close this issue.

2 participants