Skip to content

[Bug]: certain modules fail when parsing new NetBox-Docker version string format #1381

Open
@riyad

Description

@riyad

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 ?

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