netbox-community / ansible_modules

NetBox modules for Ansible using Ansible Collections
GNU General Public License v3.0
330 stars 213 forks source link

[Bug]: netbox_provider module - deprecated API parameters #1021

Open chuegel opened 1 year ago

chuegel commented 1 year ago

Ansible NetBox Collection version

v3.13.0

Ansible version

ansible [core 2.14.3]

NetBox version

v3.4.6

Python version

3.11

Steps to Reproduce

As of v3.13.0 the netbox.netbox.netbox_provider module supports following parameters:

portal_url
noc_contact
admin_contact

but Netbox has removed these in the API. All contact relevant informations are linked via the api/tenancy/contacts/ API endpoint. I guess the above are deprecated

Netbox v.3.4.6 expects following contact parameters:

contact
contact_role
contact_group

which are defined by the netbox.netbox.netbox_contact module.

Expected Behavior

To be able to assign provider contact information

Observed Behavior

Ansible fails with:

failed: [localhost] (item=Colt) => {"ansible_loop_var": "circuit_provider", "changed": false, "circuit_provider": {"account": "FRY211", "admin_contact": "noc@colt.de", "comments": "Colt Internet Provider", "name": "Colt", "noc_contact": "noc@colt.de", "portal_url": "https://my.colt.de"}, "msg": "admin_contact does not exist on existing object. Check to make sure valid field."}
chuegel commented 1 year ago

Related to: https://github.com/netbox-community/ansible_modules/issues/965

sc68cal commented 1 year ago

What was the last version of the NetBox API where portal_url, noc_contact, admin_contact were supported? We will need to do a version check for the NetBox API version and send those parameters when it's a version of NetBox that has those, and then for versions where they introduced the new API, use that API.

We have an example of that in the Cable API - https://github.com/netbox-community/ansible_modules/blob/devel/plugins/module_utils/netbox_dcim.py#L192

saruter commented 1 year ago

What was the last version of the NetBox API where portal_url, noc_contact, admin_contact were supported? We will need to do a version check for the NetBox API version and send those parameters when it's a version of NetBox that has those, and then for versions where they introduced the new API, use that API.

We have an example of that in the Cable API - https://github.com/netbox-community/ansible_modules/blob/devel/plugins/module_utils/netbox_dcim.py#L192

I think in 3.4.0 there was the breaking change where the portal_url, noc_contact, admin_contact were removed. So last version supported should be 3.3.10 according to the release notes: https://github.com/netbox-community/netbox/releases/tag/v3.4.0

sc68cal commented 1 year ago

OK - since we only officially support the current version and the last two releases, we may not even need to deal with a compatibility layer. Thanks for doing the research @saruter