-
Notifications
You must be signed in to change notification settings - Fork 254
Description
Ansible NetBox Collection version
v3.21.0
Ansible version
core version: 2.16.14
NetBox version
v4.2.6
Python version
3.11
Steps to Reproduce
Create a host with a physical and a virtual interface
Create the same MAC address on both virtual interfaces:
Assign the MAC address as primary on both virtual interfaces. This should be possible as it are actually 2 separate mac_address objects, each assigned to a different interface:
- name: Create MAC addresses
delegate_to: localhost
netbox.netbox.netbox_mac_address:
netbox_url: "{{ netbox_url }}"
netbox_token: "{{ netbox_token }}"
data:
assigned_object:
device: Test host
name: "{{ item }}"
mac_address: AA:BB:CC:DD:EE:FF
query_params:
- assigned_object
- name
loop:
- Gig-E1
- virtual1
register: netbox_mac_address_result
- name: Set NIC's Primary MAC addresses
delegate_to: localhost
netbox.netbox.netbox_device_interface:
netbox_url: "{{ netbox_url }}"
netbox_token: "{{ netbox_token }}"
data:
device: Test host
name: "{{ item.item }}"
primary_mac_address: AA:BB:CC:DD:EE:FF
loop: "{{ netbox_mac_address_result.results }}"
Expected Behavior
MAC address object assigned to interface Gig-E1 on host Test host is set as primary_mac_address on interface Gig-E1
MAC address object assigned to interface virtual1 on host Test host is set as primary_mac_address on interface virtual1
Observed Behavior
Attempt to assign MAC address as primary mac adress of an interface results in the error:
msg: More than one result returned for primary_mac_address
Despite the fact that there is only one unique mac address defined on each interface. It only happens to be the same mac_address
string for eacht of those interfaces.
I have tried passing the mac address object id as primary_mac_address
:
- name: Set NIC's Primary MAC addresses
delegate_to: localhost
netbox.netbox.netbox_device_interface:
netbox_url: "{{ netbox_url }}"
netbox_token: "{{ netbox_token }}"
data:
device: Test host
name: "{{ item.item }}"
primary_mac_address:
id: "{{ item.mac_address.id "}}
loop: "{{ netbox_mac_address_result.results }}"
But this results in the error:
msg: 'Could not resolve id of primary_mac_address: {''id'': ''1147''}'
Passing the full mac_address object as primary_mac_address
yields the same error.
It seems that the primary_mac_address
parameter only accepts an actual MAC address string but then searches for it without considering the assigned_object being the same as the device_interface where we try to set the primary_mac_address for.