You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a new device in Netbox using netbox.netbox.netbox_device:
- name: Create host device in Netboxnetbox.netbox.netbox_device:
netbox_token: "redacted"netbox_url: "redacted"data:
device_role: ansible_unknown # yes, this is defineddevice_type: unknown # yes, this is definedface: Frontname: test-host-multihomeposition: 30rack: redactedsite: redactedstatus: Planned
Observe failure
Expected Behavior
We expect the latest version of the Ansible netbox.netbox.netbox_device module (v3.14.0 as of 2023/09/20) to work with v3.6.1 of Netbox.
Observed Behavior
This exact scenario worked with the provided example and same version of the Netbox Ansible collection with v3.5.9 before we upgraded to v3.6.1, and now fails since Netbox was upgraded. Below is the full error message for the task:
TASK [netbox_host : Create host device in Netbox netbox_token=redacted, netbox_url=redacted, validate_certs=True, data={'name': 'test-host-multihome', 'device_role': 'ansible_unknown', 'device_type': 'unknown', 'face': 'Front', 'position': '30', 'rack': 'redacted', 'serial': '', 'site': 'redacted', 'status': 'Planned'}, _ansible_check_mode=False, _ansible_no_log=False, _ansible_debug=False, _ansible_diff=False, _ansible_verbosity=3, _ansible_version=2.15.1, _ansible_module_name=netbox.netbox.netbox_device, _ansible_syslog_facility=LOG_USER, _ansible_selinux_special_fs=['fuse', 'nfs', 'vboxsf', 'ramfs', '9p', 'vfat'], _ansible_string_conversion_action=warn, _ansible_socket=None, _ansible_shell_executable=/bin/sh, _ansible_keep_remote_files=False, _ansible_tmpdir=/tmp/ansible-tmp-1695238373.2334616-24558-81632491605377/, _ansible_remote_tmp=/tmp] ***task path: /home/redacted/git/configMgmt/ansible/roles/netbox_host/tasks/host_add.yml:2The full traceback is:
File "/tmp/ansible_netbox.netbox.netbox_device_payload_3ja8ax04/ansible_netbox.netbox.netbox_device_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 1289, in _create_netbox_objectnb_obj = nb_endpoint.create(data)^^^^^^^^^^^^^^^^^^^^^^^^File "/home/redacted/.local/lib/python3.11/site-packages/pynetbox/core/endpoint.py", line 415, in create).post(args[0] if args else kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/redacted/.local/lib/python3.11/site-packages/pynetbox/core/query.py", line 357, in postreturn self._make_call(verb="post", data=data)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/redacted/.local/lib/python3.11/site-packages/pynetbox/core/query.py", line 247, in _make_callraise RequestError(req)fatal: [localhost]: FAILED! => changed=false invocation:
module_args:
cert: nulldata:
airflow: nullasset_tag: nullcluster: nullcomments: nullcustom_fields: nulldescription: nulldevice_role: ansible_unknowndevice_type: unknownface: Frontlocal_context_data: nulllocation: nullname: test-host-multihomeplatform: nullposition: 30primary_ip4: nullprimary_ip6: nullrack: redactedserial: ''site: redactedstatus: Plannedtags: nulltenant: nullvc_position: nullvc_priority: nullvirtual_chassis: nullnetbox_token: VALUE_SPECIFIED_IN_NO_LOG_PARAMETERnetbox_url: redactedquery_params: nullstate: presentvalidate_certs: truemsg: '{"role":["This field is required."]}'
This appears to be a change in the Netbox API. What was once device_role appears to now be role, which does not appear to be handled in the Ansible module. This effectively prevents any Ansible automation to create new host devices or update their roles.
The text was updated successfully, but these errors were encountered:
For those like me that need this fix ahead of a release, you can do so by installing the collection by hash with ansible-galaxy. You can do so by creating this requirements.yml file:
Ansible NetBox Collection version
v3.14.0
Ansible version
NetBox version
v3.6.1
Python version
3.11
Steps to Reproduce
netbox.netbox.netbox_device
:Expected Behavior
We expect the latest version of the Ansible
netbox.netbox.netbox_device
module (v3.14.0
as of 2023/09/20) to work withv3.6.1
of Netbox.Observed Behavior
This exact scenario worked with the provided example and same version of the Netbox Ansible collection with
v3.5.9
before we upgraded tov3.6.1
, and now fails since Netbox was upgraded. Below is the full error message for the task:This appears to be a change in the Netbox API. What was once
device_role
appears to now berole
, which does not appear to be handled in the Ansible module. This effectively prevents any Ansible automation to create new host devices or update their roles.The text was updated successfully, but these errors were encountered: