Last active
July 8, 2021 07:24
-
-
Save nomaster/c5a0b1a904a9c1342fcfd6b2df75017e to your computer and use it in GitHub Desktop.
NetBox inventory for Ansible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
plugin: netbox.netbox.nb_inventory | |
cache: True | |
cache_connection: .inventory | |
cache_plugin: jsonfile | |
plurals: False | |
group_by: | |
- platform | |
- role | |
- region | |
# export NETBOX_API=https://your.net.box | |
# export NETBOX_TOKEN=YourPersonalNetBoxAccessToken | |
# ansible-inventory -i netbox_inventory.yml --list |
Also, it will cache the result of the NetBox API call for an hour in the directory .inventory
. To purge the cache, simply remove this dir.
The NetBox API is somewhat slow, see issue netbox-community/netbox#6423
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fetches the Ansible inventory from your NetBox. It will group your devices by some parameters, which seem generally useful to me - feel free to change!