Netbox dynamic inventory script for Ansible - Python

I use Ansible however and whenever I have a chance to do, because Ansible rocks! However nowadays I don't use Ansible as a main configuration management tool at work (but SaltStack).

Ansible's "Dynamic inventory" is one of nice features, where you can use an external service as inventory for Ansible instead the basic text-based ini file.

So you can use AWS EC2 as inventory of your hosts, or maybe OpenStack, or whatever ... you actually can use any source inventory for Ansible, and you able to write your own "External Inventory Script".

I also loved "Netbox" from DigitalOcean network engineering team! It's an IP address management (IPAM) and data center infrastructure management (DCIM) tool. It's nice, modern, and has good APIs ... so it's a pretty nice option to serve as a "Source of Truth".

Netbox is really helpful especially when you are working with a hybrid could! So I decided to write an Ansible external inventory script to get use of it.

Developing dynamic inventory sources for Ansible is pretty easy! The script conventions are straightforward and Ansible doesn't care about language of script, JSON output that's all that matters (but of course if you want to push it to the upstream, it should be Python).

On the other hand I played with a lot of new stuff here ... PyPi packaging, writing unit test with pytest, setup.py file, some CI tricks, and some Pythonic methods here and there.

More information about this inventory module are in its main repo:
Netbox dynamic inventory script.

Powered by Blogger.

Hello, my name is Ahmed AbouZaid, I'm a passionate Tech Lead DevOps Engineer. 👋

With 16+ years of open-source contributions, 12+ years of professional hands-on experience in DevOps, and an M.Sc. in Data Engineering from Edinburgh Napier University (UK), I enjoy facilitating the growth of both businesses and individuals.

I specialize in Cloud-Native and Kubernetes. I'm also a Free/Open source geek and book author. My favorite topics are DevOps transformation, automation, data, and metrics.

Contact Me


Email *

Message *

Start Your DevOps Engineer Journey!

Start Your DevOps Engineer Journey!
Start your DevOps career for free the Agile way in 2024 with the Dynamic DevOps Roadmap ⭐

Latest Post

2023 Highlights

Image generated with Craiyon . Finally, 2023 is over! What a year! One more crazy year, but it was the culmination ...

Popular Posts

Blog Archive