Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Breaking changes in 3.6.0, device_role -> role #1061

Closed
shaul75 opened this issue Sep 2, 2023 · 3 comments · Fixed by #1066
Closed

[Bug]: Breaking changes in 3.6.0, device_role -> role #1061

shaul75 opened this issue Sep 2, 2023 · 3 comments · Fixed by #1066
Labels
bug Something isn't working

Comments

@shaul75
Copy link

shaul75 commented Sep 2, 2023

PR: #1062

Ansible NetBox Collection version

v3.14.0

Ansible version

https://github.com/netbox-community/netbox/releases/tag/v3.6.0

The device_role field on the Device model has been renamed to role. The device_role field has been temporarily retained on the REST API serializer for devices for backward compatibility, but is read-only.

NetBox version

v3.6.0

Python version

3.10

Steps to Reproduce

      netbox.netbox.netbox_device:
        data:
          name: "{{ ansible_facts['product_name'] }}"
          device_type: "{{ ansible_facts['product_name'] }}"
          device_role: 1
          site: 1
        state: present

Expected Behavior

Device is created/updated

Observed Behavior

{"role":["This field is required."]}
fatal: [10.0.20.10 -> localhost]: FAILED! => {
    "changed": false
}
@shaul75 shaul75 added the bug Something isn't working label Sep 2, 2023
@sthierolf
Copy link

sthierolf commented Sep 10, 2023

Can confirm this bug in latest NetBox version 3.6.1 too.

Workaround:
By manually adding the device first (this means: device exists) and then running Ansible role against that device (to have other data done automatically) the error is not thrown.
Eventually this workaround helps for 1-5 devices, but it is no fun for 100s of devices.

@gtherond
Copy link

gtherond commented Sep 12, 2023

I do confirm, the issue comes from the following upstream API breaking change: netbox-community/netbox#6391

They did put device_role field as a RO one while the RW field is now named role.
A simple quick and dirty fix would be to change the device_role mapping to role instead of device_role api field.
in here:

"device_roles": "device_role",

@BackblazeJeremy
Copy link

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:

roles: []
collections:
  - name: https://github.com/netbox-community/ansible_modules.git
    type: git
    version: 5f497b5d0e5524529636eea68466bfbec203dd4b

Then apply it with ansible-galaxy install -r requirements.yml. This worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants