Query Netbox with Ansible to generate an Ansible inventory

1.
Make sure you use Ansible version >= 2.10.x
pip3 install –user –upgrade pip
pip3 install –user –upgrade ansible

2.
Install pynetbox
apt install python3-pip
pip install pynetbox –upgrade

3.
Install the Ansible module
ansible-galaxy collection install netbox.netbox

4.
Simple netbox-inventory YAML
# 02-netbox-inventory.yml

plugin: netbox.netbox.nb_inventory
api_endpoint: https://netbox.heaven.grp
token: api-key
validate_certs: false
config_context: false
group-by:
  – tags

5.
Install Netbox
Follow the Netbox installation guide
https://docs.netbox.dev/en/stable/installation/
Fill in some live in there

6.
Testing the generation of the Netbox inventory via ansible-inventory
ansible-inventory -i 02-netbox-inventory.yml –list