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]: certain modules fail when parsing new NetBox-Docker version string format #1381

Open
riyad opened this issue Feb 8, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@riyad
Copy link

riyad commented Feb 8, 2025

Ansible NetBox Collection version

v3.20.0

Ansible version

ansible [core 2.18.1]
  config file = /home/riyad/Projects/ansible-netbox/ansible.cfg
  configured module search path = ['/home/riyad/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/riyad/Projects/ansible-netbox/.venv/lib/python3.12/site-packages/ansible
  ansible collection location = /home/riyad/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/riyad/Projects/ansible-netbox/.venv/bin/ansible
  python version = 3.12.7 (main, Jan 17 2025, 16:55:27) [GCC 14.2.0] (/home/riyad/Projects/ansible-netbox/.venv/bin/python)
  jinja version = 3.1.5
  libyaml = True

NetBox version

4.2.3-Docker-3.2.0 (from https://github.com/netbox-community/netbox-docker)

Python version

3.11

Steps to Reproduce

Run a module that checks the NetBox version against the NetBox-Docker version starting from 3.2.0 . In my case at least the netbox_rack is affected.

Expected Behavior

Should work as before.

Observed Behavior

Running the netbox_rack module against the Docker version of NetBox seems to fails with the following error:

[...]
The full traceback is:
Traceback (most recent call last):
  File "master:/home/riyad/Projects/ansible-netbox/library/mitogen/ansible_mitogen/runner.py", line 1039, in _run
    self._run_code(code, mod)
  File "master:/home/riyad/Projects/ansible-netbox/library/mitogen/ansible_mitogen/runner.py", line 1003, in _run_code
    exec(code, vars(mod))
  File "master:/home/riyad/.ansible/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_rack.py", line 346, in <module>
  File "master:/home/riyad/.ansible/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_rack.py", line 342, in main
  File "master:/home/riyad/.ansible/collections/ansible_collections/netbox/netbox/plugins/module_utils/netbox_dcim.py", line 130, in run
    if Version(self.full_version) >= Version("4.1.0"):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/riyad/Projects/ansible-netbox/.venv/lib/python3.12/site-packages/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: {version!r}")
packaging.version.InvalidVersion: Invalid version: '4.2.3-Docker-3.2.0'
[...]

This started after updating to version 3.2.0 of the NetBox-Docker project where it seems to have started to include its version number in the version string as well (i.e. "4.2.3-Docker-3.2.0").

May be caused by netbox-community/netbox-docker#1380 ?

@riyad riyad added the bug Something isn't working label Feb 8, 2025
@Jurka007
Copy link

I am getting something similar with netbox.netbox.netbox_virtual_machine and netbox.netbox.netbox_vm_interface modules, python3.12

"msg": "Failed to establish connection to NetBox API"

The full traceback is:
  File "/var/folders/s4/bh0s3kz51g166t27lwwz9zbw0000gp/T/ansible_netbox.netbox.netbox_virtual_machine_payload_oguhsl20/ansible_netbox.netbox.netbox_virtual_machine_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 811, in _connect_netbox_api
    self.version = nb.version
                   ^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pynetbox/core/api.py", line 113, in version
    ).get_version()
      ^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pynetbox/core/query.py", line 198, in get_version
    raise RequestError(req)

@rodvand
Copy link
Contributor

rodvand commented Feb 12, 2025

Can I suggest you raise this issue with the netbox-docker repository? I find it a bit strange that the netbox-docker image changes the netbox-version in /api/status to indicate it's running a docker image. I would expect the netbox-version to be the actual netbox version running, not that the netbox version is running using docker.

@rodvand
Copy link
Contributor

rodvand commented Feb 12, 2025

After investigating this a bit more I've opened an issue in the main NetBox repository: netbox-community/netbox#18635

@riyad
Copy link
Author

riyad commented Feb 13, 2025

Thank you for looking into this. Is there any way we could help?

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

No branches or pull requests

3 participants