ansible_modules icon indicating copy to clipboard operation
ansible_modules copied to clipboard

[Bug]: assigned_object_type not usable as query_parameter in netbox.netbox.netbox_mac_address module.

Open tortuegenialez opened this issue 2 months ago • 2 comments

Ansible NetBox Collection version

3.21.0

Ansible version

ansible [core 2.18.3]
  config file = /home/user/work/sources/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/user/work/sources/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

NetBox version

NetBox Community v4.4.1-Docker-3.4.0

Python version

3.11

Steps to Reproduce

Use a task with the mac address module:

    - name: Create MAC address with assignation to the host and interface
      netbox.netbox.netbox_mac_address:
        netbox_url: "{{ netbox_url }}"
        netbox_token: "{{ netbox_token }}"
        data:
          mac_address: "00:11:22:33:44:55"
          assigned_object:
            device: "host01"
            name: "eth0"
        query_params:
          - assigned_object_type

Expected Behavior

Netbox would set or return the mac address

Observed Behavior

An error message is returned: "{\"assigned_object_type\":[\"Select a valid choice. That choice is not one of the available choices.\"

This choice seems to be valid. When setting a wrong choice in the query_params (test_choice in this exemple) the module returns a list of valid choices: One or more of the kwargs provided are invalid for mac_address, provided kwargs: assigned_object, assigned_object_id, assigned_object_type, mac_address. Acceptable kwargs: test_choice.

Note that acceptable kwargs and provided kwargs are inverted.

tortuegenialez avatar Oct 22 '25 14:10 tortuegenialez

could you explain why you need query_params here?

chaeynz avatar Nov 04 '25 00:11 chaeynz

I'm using query_params to differentiate interface having the same name on a virtual machine and a device.

tortue-ipsos avatar Nov 14 '25 08:11 tortue-ipsos