Ansible netbox.netbox.netbox_vm_interface does not add MAC address #10836

Closed
opened 2025-12-29 21:36:29 +01:00 by adam · 5 comments
Owner

Originally created by @boredomwontgetus on GitHub (Mar 3, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.2.4

Python Version

3.10

Steps to Reproduce

 - name: Create primary interface and assign to VM
    netbox.netbox.netbox_vm_interface:
      netbox_url: http://local.local
      netbox_token: mytoken
      data:
        virtual_machine: vm01
        name: ens3
        mac_address: "50:20:10:30:AA:BB"
        enabled: true
      state: present

This creates the interface just fine but does not add the MAC.

Do i have to add the MAC to Netbox before using this module? If so, what ansible module would i use for that?

Expected Behavior

The Ansible module netbox.netbox.netbox_vm_interface adds the mac address to an interface.

Observed Behavior

Every ansible run results in state "changed" unless the MAC address is added to Netbox manually. So it somehow understands that the MAC is missing in Netbox yet fails silently to add it.

Originally created by @boredomwontgetus on GitHub (Mar 3, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.2.4 ### Python Version 3.10 ### Steps to Reproduce ``` - name: Create primary interface and assign to VM netbox.netbox.netbox_vm_interface: netbox_url: http://local.local netbox_token: mytoken data: virtual_machine: vm01 name: ens3 mac_address: "50:20:10:30:AA:BB" enabled: true state: present ``` This creates the interface just fine but does not add the MAC. Do i have to add the MAC to Netbox before using this module? If so, what ansible module would i use for that? ### Expected Behavior The Ansible module [netbox.netbox.netbox_vm_interface](https://docs.ansible.com/ansible/latest/collections/netbox/netbox/netbox_vm_interface_module.html#ansible-collections-netbox-netbox-netbox-vm-interface-module) adds the mac address to an interface. ### Observed Behavior Every ansible run results in state "changed" unless the MAC address is added to Netbox manually. So it somehow understands that the MAC is missing in Netbox yet fails silently to add it.
adam added the type: bug label 2025-12-29 21:36:29 +01:00
adam closed this issue 2025-12-29 21:36:29 +01:00
Author
Owner

@AskskwBv8T2nrm4Qnj commented on GitHub (Mar 3, 2025):

Hi,

I'm running into a similar issue on v4.2.4 using Pynetbox (7.4.1).
A simple query such as the following does not update the VM Interface with a new MAC-address

updateinterface = nb.virtualization.interfaces.update([
    {'id': 6176,
     'mac_address': "FA:16:3E:AA:BB:CC"
     }
])

Executing the query gives no error, NetBox seems to just completely ignore it.

Thank you.

@AskskwBv8T2nrm4Qnj commented on GitHub (Mar 3, 2025): Hi, I'm running into a similar issue on v4.2.4 using Pynetbox (7.4.1). A simple query such as the following does not update the VM Interface with a new MAC-address ``` updateinterface = nb.virtualization.interfaces.update([ {'id': 6176, 'mac_address': "FA:16:3E:AA:BB:CC" } ]) ``` Executing the query gives no error, NetBox seems to just completely ignore it. Thank you.
Author
Owner

@tomasz-c commented on GitHub (Mar 3, 2025):

This is because MAC addresses are now separate objects. This is described in the changelog: https://github.com/netbox-community/netbox/releases/tag/v4.2.0

Personally, I also liked the previous way.

If you use a single MAC per interface it makes it much more difficult to manage MAC addresses from the API (pynetbox). Or maybe a compromise could be worked out to allow the use of primary_mac_address as a direct interface attribute and all the “magic” (i.e. adding/changing the MAC and assigning it to the interface) could be done underneath by Netbox?

@tomasz-c commented on GitHub (Mar 3, 2025): This is because MAC addresses are now separate objects. This is described in the changelog: https://github.com/netbox-community/netbox/releases/tag/v4.2.0 Personally, I also liked the previous way. If you use a single MAC per interface it makes it much more difficult to manage MAC addresses from the API (pynetbox). Or maybe a compromise could be worked out to allow the use of `primary_mac_address` as a direct interface attribute and all the “magic” (i.e. adding/changing the MAC and assigning it to the interface) could be done underneath by Netbox?
Author
Owner

@AskskwBv8T2nrm4Qnj commented on GitHub (Mar 4, 2025):

It seems I made a wrong assumption about the phasing out of the mac_address attribute. I assumed that the mac_address attribute may still be populated, as performing a query gives no error or warning...

Personally I would prefer being able to set a single MAC-address directly on an Interface via an attribute such as primary_mac_address. But for now, I will look into using the new default way of associating MAC-addresses!

@AskskwBv8T2nrm4Qnj commented on GitHub (Mar 4, 2025): It seems I made a wrong assumption about the phasing out of the mac_address attribute. I assumed that the mac_address attribute may still be populated, as performing a query gives no error or warning... Personally I would prefer being able to set a single MAC-address directly on an Interface via an attribute such as `primary_mac_address`. But for now, I will look into using the new default way of associating MAC-addresses!
Author
Owner

@arthanson commented on GitHub (Mar 4, 2025):

This does not look like a bug, so closing this. If you wish to have the functionality changes, please open this as a feature request. Also, if possible in a bug report like this can you please add repro steps using curl to the API directly instead of using something like Ansible as we don't normally have other software like this installed and it makes trying to reproduce it much harder.

@arthanson commented on GitHub (Mar 4, 2025): This does not look like a bug, so closing this. If you wish to have the functionality changes, please open this as a feature request. Also, if possible in a bug report like this can you please add repro steps using curl to the API directly instead of using something like Ansible as we don't normally have other software like this installed and it makes trying to reproduce it much harder.
Author
Owner

@Andres1357 commented on GitHub (Mar 5, 2025):

I created a related feature request #18821

@Andres1357 commented on GitHub (Mar 5, 2025): I created a related feature request #18821
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10836