Skip to content

[Bug]: netbox.netbox.netbox_device_interface return changed for old mac_address but doesn't change it #1502

@xocoru

Description

@xocoru

Ansible NetBox Collection version

v.3.21.0

Ansible version

ansible [core 2.20.1]
config file = /Users/aivanov/Git/asset-automations/ansible.cfg
configured module search path = ['/Users/aivanov/Git/asset-automations/modules']
ansible python module location = /Users/aivanov/Git/asset-automations/venv/lib/python3.13/site-packages/ansible
ansible collection location = /Users/aivanov/Git/asset-automations/collections
executable location = /Users/aivanov/Git/asset-automations/venv/bin/ansible
python version = 3.13.7 (v3.13.7:bcee1c32211, Aug 14 2025, 19:10:51) [Clang 16.0.0 (clang-1600.0.26.6)] (/Users/aivanov/Git/asset-automations/venv/bin/python3.13)
jinja version = 3.1.6
pyyaml version = 6.0.3 (with libyaml v0.2.5)

NetBox version

v4.4.8

Python version

3.11

Steps to Reproduce

  1. Run task
- name: Updating management interface items in Netbox
  environment:
    REQUESTS_CA_BUNDLE: "{{ cert_path }}"
    SSL_CERT_FILE: "{{ cert_path }}"
  delegate_to: localhost
  netbox.netbox.netbox_device_interface:
    validate_certs: "{{ pdu_panduit_netbox_validate_certs }}"
    netbox_url: "{{ pdu_panduit_netbox_host }}"
    netbox_token: "{{ pdu_panduit_netbox_token }}"
    data:
      device: "{{ inventory_hostname }}"
      name: "management"
      mac_address: "{{ pdu_panduit_facts.main.mac_addr | replace('-', ':') | lower }}"
      type: "100base-tx"
      mgmt_only: true
    state: present
  1. Observe output
TASK [pdu_panduit : Updating management interface items in Netbox] **********************************************************************************************************************************************************************
--- before
+++ after
@@ -1,3 +1,3 @@
 {
-    "mac_address": null
+    "mac_address": "00:0F:9C:XX:XX:XX"
 }

changed: [pdu-abcd -> localhost]
  1. See no changes in Netbox. Because it expects to create the MAC address via another module.

Expected Behavior

It must return an error indicating that the MAC address should be created first, or force-creating it under the hood to maintain backward compatibility.

Observed Behavior

The task shows changes as they were made, but it is not true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions