Skip to content

Conversation

gs-adn
Copy link

@gs-adn gs-adn commented Sep 12, 2025

Related Issue

#1413

New Behavior

Allowing raw parameters permits the following construct to lookup mac addresses in a different way to get an unique object, for example by id:

netbox_device_interface:
  primary_mac_address:
    id: "{{ mac_address_object_id }}"

Contrast to Current Behavior

Coercing primary_mac_address to str prevents using dict constructs to point to a specific object in netbox, instead always searching for an entry with the plaintext mac.
This key for the object is not guaranteed to be unique, resulting in errors when multiple objects are returned.

Discussion: Benefits and Drawbacks

This fixes a bug when the same mac address is used by multiple items in netbox 4.2+

Changes to the Documentation

No changes (this allows the already-documented construct described here to be used)

Proposed Release Note Entry

netbox_device_interface: Fix assigning primary_mac_address by id

Double Check

  • I have read the comments and followed the CONTRIBUTING.md.
  • I have explained my PR according to the information in the comments or in a linked issue.
  • My PR targets the devel branch.

@gs-adn

This comment was marked as resolved.

Coercing primary_mac_address to str prevents using dict constructs to
point to a specific object in netbox, instead always searching for an
entry with the plaintext mac.
This key for the object is not guaranteed to be unique, resulting in
errors when multiple objects are returned.

Allowing raw parameters permits the following construct to lookup mac
addresses in a different way to get an unique object, for example by id:
```yaml
netbox_device_interface:
  primary_mac_address:
    id: "{{ mac_address_object_id }}"
```

Fixes: netbox-community#1413
@gs-adn gs-adn force-pushed the fix-duplicate-macs-lookup branch from 734f2fc to d3880fc Compare September 15, 2025 06:04
@gs-adn gs-adn force-pushed the fix-duplicate-macs-lookup branch from 3aee325 to 8f8bbdf Compare September 19, 2025 10:12
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 this pull request may close these issues.

1 participant