Skip to content

[Bug]: Updating Permissions always lists object_types to be changed #1486

@dhoffend

Description

@dhoffend

Ansible NetBox Collection version

v3.21.0

Ansible version

ansible [core 2.15.13]

When using netbox.netbox.netbox_permission to update given permissions, the field object_types always gets return as changed, cause the list is compared as list, not set. The order of the object_types it applies to are not important.

This is similar to tags

I would propose to
a) bring this in line with the pynetbox response (which defines fields are sets)
b) define the field object_types as set as well (pynetbox as well)

NetBox version

v4.4.6

Python version

3.9

Steps to Reproduce

- name: update permissions
  netbox.netbox.netbox_permission:
    netbox_url: ENDPOINT_URL
    netbox_token: API_TOKEN
    data:
      name: example-permission
      enabled: true
      actions: ['view', 'add', 'change', 'delete']
      object_types:
        - dcim.interface
        - dcim.module
        - dcim.device
      constraints: {}

Depending on the response and your given order, ansible always detects a change.

Expected Behavior

When the list of object_types the permissions applies to doesn't change, ansible should not report that something has changed.

Observed Behavior

[...]

changed: [netbox-vm] => (item=ipam-perms)
ok: [netbox-vm] => (item=ipam-perms)
--- before
+++ after
@@ -1,8 +1,8 @@
     object_types:
+    - ipam.ipaddress
+    - ipam.prefix
     - ipam.vrf
-    - ipam.prefix
-    - ipam.iprange
-    - ipam.ipaddress
     - ipam.vlangroup
     - ipam.vlan
+    - ipam.iprange

[...]

As you see, the order ist always random (iprange > vrf ....)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions