netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
567 stars 168 forks source link

[pynetbox.ansible_module] unexpected keyword argument 'private_key' since 7.0.1 release #530

Closed dauphinpasdroit closed 1 year ago

dauphinpasdroit commented 1 year ago

Hello,

Since the 7.0.1 release, I encounter this error message:

fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'netbox.netbox.nb_lookup'. Error was a , original message: __init__() got an unexpected keyword argument 'private_key'"}

With the version 7.0.0 it works perfectly fine.

It seems like to be a bug from the new release.

markkuleinio commented 1 year ago

pynetbox 7.x is only compatible with NetBox 3.3+, so the non-NetBox 3.3+ compatible features were removed in 7.0.1. The private_key argument for pynetbox.api() was one such feature (only usable with NetBox 2.11 and older).

If you need the private key for use in older NetBox, you need to use some older pynetbox version.

Or, maybe the plugin you are using needs some update.

dauphinpasdroit commented 1 year ago

Thank you for your answer.

I use pynetbox through Ansible with the netbox collection. To be more specific, I use the netbox.netbox.nb_lookup module. I use the last version of the collection.

The thing that I don't understand, it's that I don't use the private_key feature at all.

I rolled back the pynetbox version to 7.0.0 so it's working now, but I'm not sure to fully understand everything here.

markkuleinio commented 1 year ago

I'd recommend you to search for peer assistance among other users of that plugin, and to notify the module author that legacy features (private_key) don't work with current pynetbox anymore, so they may want to release update as well.

equinoxefr commented 1 year ago

@alphaxr6 same issue here... I'm going to have a look at the list of issues for ansible collection

equinoxefr commented 1 year ago

@alphaxr6 as a very very dirty workaround, you can edit netbox/plugins/lookup/nb_lookup.py and comment out this lines:

#        "secret-roles": {"endpoint": netbox.secrets.secret_roles},
#        "secrets": {"endpoint": netbox.secrets.secrets},

and

            netbox = pynetbox.api(
                netbox_api_endpoint,
                token=netbox_api_token if netbox_api_token else None,
                #private_key=netbox_private_key,
                #private_key_file=netbox_private_key_file,
            )
equinoxefr commented 1 year ago

I opened a bug report in netbox ansible collection repository. Feel free to add more information :)

dauphinpasdroit commented 1 year ago

Thank you @equinoxefr

I saw that the bug was known and netbox collection for ansible team is working on it. I'll close this topic.

Thank you for your help all :)