You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time the netbox inventory starts, the first thing it does is read the entire openapi schema. This is slow, as it is generated dynamically - it adds about an 8 second overhead, and transfers about 800KB of data over the network.
STEPS TO REPRODUCE
# time ansible -m ping wrn-vm1
wrn-vm1 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
real 0m11.870s
user 0m1.450s
sys 0m0.197s
But if I frig it to read a local copy of the openapi schema (see below):
# time ansible -m ping wrn-vm1
wrn-vm1 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
real 0m3.964s
user 0m1.306s
sys 0m0.166s
This is about a 3-times speedup overall.
EXPECTED RESULTS
I would like to have the openapi schema cached.
Note: this is different to inventory caching, which can be configured, but caches the entire lookup results. I still want the most up-to-date data returned from Netbox, but without the overhead of fetching the schema.
ACTUAL RESULTS
The openapi schema is fetched in its entirety every time the inventory is accessed.
PROPOSAL
Create a cache file automatically somewhere (e.g. in the same directory that ansible uses to keep state), and ignore it if it's more than (say) 24 hours old.
As a proof-of-concept, I frigged the inventory to read a static file /etc/ansible/netbox-openapi.json if it exists.
It works as well as it goes. If you've not used it for 24 hours you still get the slow startup though. I think the cache timeout could safely be made very long (e.g. 6 months) and be wiped by ./upgrade.sh
In the mean time, a nightly cronjob will probably do the trick:
ISSUE TYPE
SOFTWARE VERSIONS
Ansible:
2.10.8
Netbox:
v2.11.3
Collection:
v3.0.1
SUMMARY
Every time the netbox inventory starts, the first thing it does is read the entire openapi schema. This is slow, as it is generated dynamically - it adds about an 8 second overhead, and transfers about 800KB of data over the network.
STEPS TO REPRODUCE
But if I frig it to read a local copy of the openapi schema (see below):
This is about a 3-times speedup overall.
EXPECTED RESULTS
I would like to have the openapi schema cached.
Note: this is different to inventory caching, which can be configured, but caches the entire lookup results. I still want the most up-to-date data returned from Netbox, but without the overhead of fetching the schema.
ACTUAL RESULTS
The openapi schema is fetched in its entirety every time the inventory is accessed.
PROPOSAL
Create a cache file automatically somewhere (e.g. in the same directory that ansible uses to keep state), and ignore it if it's more than (say) 24 hours old.
As a proof-of-concept, I frigged the inventory to read a static file
/etc/ansible/netbox-openapi.json
if it exists.The text was updated successfully, but these errors were encountered: