I wanted to share some information about an open source tool I have found some time ago which helps you to keep track of your infrastructure assets and configuration items. The name is NetBox which is an DCIM (Datacenter infrastructure management) and IPAM (IP address management) tool. NetBox was started by the network engineering team from DigitalOcean, specifically to address the needs of network and infrastructure engineers.
We all know that documentation is something no one wants to do, and no one has time for. What makes NetBox interesting is that not only does it focus on infrastructure documentation with a clean web console, it also comes with a API to push changes via the API , or use NetBox as dynamic inventory for Ansible.
Here a few screenshots showing the look and feel from NetBox:
The rack overview:
The IPAM module:
Here is an example how to add a device via the REST API, very useful if you use ZTP (zero touch provisioning) and add your switches or servers automatically to NetBox or in your automation scripts when you deploy configurations:
vagrant@netbox:~$ curl -X POST -H "Authorization: Token fde02a67ca0c248bf5695bbf5cd56975add33655" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost:80/api/dcim/devices/ --data '{ "nae": "server-9", "display_name": "server-9", "device_type": 5, "device_role": 8 , "site": 1 }' { "id": 21, "name": "server-9", "device_type": 5, "device_role": 8, "tenant": null, "platform": null, "serial": "", "asset_tag": null, "site": 1, "rack": null, "position": null, "face": null, "status": 1, "primary_ip4": null, "primary_ip6": null, "cluster": null, "virtual_chassis": null, "vc_position": null, "vc_priority": null, "comments": "", "created": "2018-04-16", "last_updated": "2018-04-16T14:40:47.787862Z" } vagrant@netbox:~$
In the web console you see the device I have just added via the REST API:
On the main NetBox Github repository page you find links for a Ansible Role or Vagrant environment.
You can use NetBox as Ansible dynamic inventory and pull out hosts information dynamically when running playbooks. Check out the Github repository I have found.
sudo apt-get install python-setuptools ansible -y git clone https://github.com/AAbouZaid/netbox-as-ansible-inventory.git cd ./netbox-as-ansible-inventory/ pip install -r ./requirements.txt sudo python setup.py install
Usage with Ansible playbook
ansible-playbook -i netbox.py ./site.yml
Please share your feedback and leave a comment.
Nice article Bernd
Thank you Ken, I have seen you are also busy writing new interesting articles on your blog. Nice, good job