Skip to content

[Bug]: nb_inventory failed '/api/dcim/devices/' #1320

@wols

Description

@wols

Ansible NetBox Collection version

v3.20.0

Ansible version

ansible [core 2.14.16]
  config file = /home/USER/path/to/ansible.cfg
  configured module search path = ['/home/USER/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/USER/path/to
  executable location = /usr/bin/ansible
  python version = 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

NetBox version

v4.1.0

Python version

3.11

Steps to Reproduce

# path/to/inventory/01_netbox.yml
---
plugin: netbox.netbox.nb_inventory

api_endpoint: http://A.B.C.D/netbox
token: 1234567890123456789012345678901234567890
validate_certs: false
config_context: false

Expected Behavior

Debian Bookworm 12.7 up to date:

The inventory works witch netbox v4.0.11 and ansible_modules v3.19.1 (despite the message Collection netbox.netbox does not support Ansible version 2.14.16).

After update to netbox v4.1.0 the error as below and ansible_module v3.20.0 brought no change.

Observed Behavior

$ ansible-inventory -i inventory/01_netbox.yml --list -vvv
ansible-inventory [core 2.14.16]
  config file = /home/USER/path/to/ansible.cfg
  configured module search path = ['/home/USER/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/USER/path/to
  executable location = /usr/bin/ansible-inventory
  python version = 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
Using /home/USER/path/to/ansible.cfg as config file
host_list declined parsing /home/USER/path/to/inventory/01_netbox.yml as it did not pass its verify_file() method
script declined parsing /home/USER/path/to/inventory/01_netbox.yml as it did not pass its verify_file() method
[WARNING]: Collection netbox.netbox does not support Ansible version 2.14.16
Using inventory plugin 'ansible_collections.netbox.netbox.plugins.inventory.nb_inventory' to process inventory source '/home/USER/path/to/inventory/01_netbox.yml'
Fetching: http://A.B.C.D/netbox/api/status
toml declined parsing /home/USER/path/to/inventory/01_netbox.yml as it did not pass its verify_file() method
[WARNING]:  * Failed to parse /home/USER/path/to/inventory/01_netbox.yml with auto plugin: '/api/dcim/devices/'
  File "/usr/lib/python3/dist-packages/ansible/inventory/manager.py", line 293, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3/dist-packages/ansible/plugins/inventory/auto.py", line 59, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/home/USER/path/to/ansible_collections/netbox/netbox/plugins/inventory/nb_inventory.py", line 2179, in parse
    self.main()
  File "/home/USER/path/to/ansible_collections/netbox/netbox/plugins/inventory/nb_inventory.py", line 2018, in main
    self.fetch_api_docs()
  File "/home/USER/path/to/ansible_collections/netbox/netbox/plugins/inventory/nb_inventory.py", line 1627, in fetch_api_docs
    for p in openapi["paths"]["/api/dcim/devices/"]["get"]["parameters"]
             ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
[WARNING]:  * Failed to parse [...] AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]:  * Failed to parse [...] AnsibleParserError(e)
[WARNING]: Unable to parse /home/wUSER/path/to/inventory/01_netbox.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    }
}

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