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]: version check error? #1329

Open
lTomBackl opened this issue Sep 27, 2024 · 2 comments
Open

[Bug]: version check error? #1329

lTomBackl opened this issue Sep 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@lTomBackl
Copy link

Ansible NetBox Collection version

v3.20.0

Ansible version

ansible [core 2.16.11]
config file = /work/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.12/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.12.6 (main, Sep 11 2024, 08:48:26) [GCC 13.2.1 20240309] (/usr/bin/python3)
jinja version = 3.1.4
libyaml = True

NetBox version

v4.1.1

Python version

3.11

Steps to Reproduce

Exception when running the following playbook to create a VM:

---
- name: Create VM
  hosts: localhost
  gather_facts: false

  vars_files:
    - /work/secrets/netbox.yml

  tasks:

    - name: Create virtual machine
      netbox.netbox.netbox_virtual_machine:
        netbox_url: "{{ netbox_url }}"
        netbox_token: "{{ netbox_token }}"
        data:
          name: Test VM
          cluster: mycluster
        state: present

I do also use nb_inventory without any issues.

Could it be, that there is a version check issue -> observed error:

... netbox_utils.py", line 782, in _version_check_greater
ValueError: not enough values to unpack (expected 2, got 1)

Thank you

Expected Behavior

create a vm object in netbox

Observed Behavior

PLAY [Create VM] ******************************************************************************************************************************************************************

TASK [Create virtual machine within NetBox] ***************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: not enough values to unpack (expected 2, got 1)
fatal: [localhost]: FAILED! => changed=false
  module_stderr: |-
    Traceback (most recent call last):
      File "/root/.ansible/tmp/ansible-tmp-1727427640.0271611-503-166887187380580/AnsiballZ_netbox_virtual_machine.py", line 107, in <module>
        _ansiballz_main()
      File "/root/.ansible/tmp/ansible-tmp-1727427640.0271611-503-166887187380580/AnsiballZ_netbox_virtual_machine.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/root/.ansible/tmp/ansible-tmp-1727427640.0271611-503-166887187380580/AnsiballZ_netbox_virtual_machine.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.netbox.netbox.plugins.modules.netbox_virtual_machine', init_globals=dict(_module_fqn='ansible_collections.netbox.netbox.plugins.modules.netbox_virtual_machine', _modlib_path=modlib_path),
      File "<frozen runpy>", line 226, in run_module
      File "<frozen runpy>", line 98, in _run_module_code
      File "<frozen runpy>", line 88, in _run_code
      File "/tmp/ansible_netbox.netbox.netbox_virtual_machine_payload_aohgjsha/ansible_netbox.netbox.netbox_virtual_machine_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_virtual_machine.py", line 267, in <module>
      File "/tmp/ansible_netbox.netbox.netbox_virtual_machine_payload_aohgjsha/ansible_netbox.netbox.netbox_virtual_machine_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_virtual_machine.py", line 262, in main
      File "/tmp/ansible_netbox.netbox.netbox_virtual_machine_payload_aohgjsha/ansible_netbox.netbox.netbox_virtual_machine_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_virtualization.py", line 25, in __init__
      File "/tmp/ansible_netbox.netbox.netbox_virtual_machine_payload_aohgjsha/ansible_netbox.netbox.netbox_virtual_machine_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 772, in __init__
      File "/tmp/ansible_netbox.netbox.netbox_virtual_machine_payload_aohgjsha/ansible_netbox.netbox.netbox_virtual_machine_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 1252, in _find_ids
      File "/tmp/ansible_netbox.netbox.netbox_virtual_machine_payload_aohgjsha/ansible_netbox.netbox.netbox_virtual_machine_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 782, in _version_check_greater
    ValueError: not enough values to unpack (expected 2, got 1)
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

PLAY RECAP ************************************************************************************************************************************************************************localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
@lTomBackl lTomBackl added the bug Something isn't working label Sep 27, 2024
@lTomBackl lTomBackl changed the title [Bug]: [Bug]: version check error? Sep 27, 2024
@eliaswimmer
Copy link

Hi @lTomBackl,

can it be, that you redirect to https?
I had the same error, when using the wrong non https URI.

best wishes
Elias

@lTomBackl
Copy link
Author

Hi @lTomBackl,

can it be, that you redirect to https? I had the same error, when using the wrong non https URI.

best wishes Elias

Hello @eliaswimmer,

thank you for your reply.

The netbox api URL is set as an environment variable, and it's set as https://...
We are also using nb_inventory, which works fine. Only the ansible netbox modules have issues.

Our netbox instance is running as a docker container, below are the logs when I execute the above mentioned playbook:

netbox-1               | ::1 - - [03/Oct/2024:11:19:37 +0000] "GET /login/ HTTP/1.1" 200 3260 "-" "curl/8.5.0"
netbox-1               | 2024/10/03 11:19:38 [info] 673688#673688 "netbox" application started
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/locations/?limit=0 HTTP/1.1" 200 10464 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/regions/?limit=0 HTTP/1.1" 200 2692 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/sites/?limit=0 HTTP/1.1" 200 174805 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/site-groups/?limit=0 HTTP/1.1" 200 2047 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/tenancy/tenants/?limit=0 HTTP/1.1" 200 40826 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/device-roles/?limit=0 HTTP/1.1" 200 6355 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/virtualization/virtual-disks/?limit=0 HTTP/1.1" 200 10300 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/platforms/?limit=0 HTTP/1.1" 200 23562 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/ipam/services/?limit=0 HTTP/1.1" 200 52 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/manufacturers/?limit=0 HTTP/1.1" 200 11807 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/racks/?limit=0 HTTP/1.1" 200 65713 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/virtualization/clusters/?limit=0 HTTP/1.1" 200 2637 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:38 +0000] "GET /api/dcim/device-types/?limit=0 HTTP/1.1" 200 159835 "-" "ansible 2.16.11 Python 3.12.6"
netbox-1               | ::1 - - [03/Oct/2024:11:19:52 +0000] "GET /login/ HTTP/1.1" 200 3260 "-" "curl/8.5.0"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:53 +0000] "GET /api/ HTTP/1.1" 403 58 "-" "python-requests/2.32.3"
netbox-1               | 192.168.1.2 - - [03/Oct/2024:11:19:53 +0000] "GET /api/status/ HTTP/1.1" 200 549 "-" "python-requests/2.32.3"
netbox-1               | ::1 - - [03/Oct/2024:11:20:08 +0000] "GET /login/ HTTP/1.1" 200 3260 "-" "curl/8.5.0"

Almost every request gets a 200, except for the "/api/" one, which gets a 403.

After reading your answer I did some further research and stumbled across this.
We are also using a reverse proxy in front of netbox, could this be the issue?

pynetbox version is 7.4.0

Thanks for any further help

Tom

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

2 participants