How To Create A Custom, Dynamic Inventory Script for Ansible

Writing a dynamic inventory script for Ansible can be useful for more than just getting a list of hosts to run a play against.  It can also function as a standalone command line utility for your infrastructure.

The first time I wrote one, I had a difficult time finding information on how to actually do it so I wanted to write about how to make one and then show an example of how it can be extended beyond a simple inventory script by adding additional flags to the scripts.

Let me set the scene, which may sound familiar: due to a lot of tech debt, there are thousands of servers–many of which are not tracked anywhere.  Continue reading “How To Create A Custom, Dynamic Inventory Script for Ansible”