Closed evangerontakis-gn closed 2 years ago
You're running a newer version of the nb_inventory
plugin against an old NetBox instance.
The README states:
To keep the code simple, we only officially support the two latest releases of NetBox and don't guarantee backwards compatibility beyond that. We do try and keep these breaking changes to a minimum, but sometimes changes to NetBox's API cause us to have to make breaking changes.
You will need to install a version of the NetBox ansible modules that lines up with the version of NetBox that you have installed.
Ansible NetBox Collection version
3.7.1
Ansible version
NetBox version
v2.2.8
Python version
3.9
Steps to Reproduce
Use nb_inventory module to create an Ansible inventory
netbox_inventory.yml file used:
Run ansible-inventory in verbose:
ansible-inventory -v --graph -i inventories/dev/netbox_inventory.yml -vvvvv
Results:
ISSUE #1
Noted in line 1404 within nb_inventory.py the expressions:
openapi["paths"]["/dcim/devices/"]["get"]["parameters"]
andopenapi["paths"]["/virtualization/virtual-machines/"]["get"]["parameters"]
but the returned contents in openapi format does NOT contain such keys like "/dcim/devices/" and "/virtualization/virtual-machines/"
The keys are instead "/api/dcim/devices/" and "/api/virtualization/virtual-machines/"
ISSUE #2
Also noted in line 922 within nb_inventory.py the expression:
if site["prefix_count"] and site["prefix_count"] > 0:
Again the returned contents from the below curl does not contain "prefix_count" key under site
curl http://<netbox_lab_url>/api/dcim/sites/?limit=0
the key seems to be "count_prefixes" maybe?
ISSUE #3
Finally in line 734 within function extract_tags(), I am getting a KeyError in
There is no tags key!
When the above issues are mitigated directly, I am successfully executing the remaining of the inventory script and receiving the generated inventory.
Expected Behavior
To receive the inventory directly without KeyErrors
Observed Behavior
All of the above issues are KeyErrors, but might be down to my old Netbox version and API changes.