To demonstrate developing an inventory plugin, we'll create one that simply prints the same host data we've been using in our mastery-hosts file. Integrating with a custom asset management system or an infrastructure provider is a bit beyond the scope of this book, so we'll simply code the systems into the plugin itself. We'll write our inventory plugin to a file in the top level of our project root named mastery-inventory.py and make it executable. We'll use Python for this file, to handle execution arguments and JSON formatting with ease:
- First, we'll need to add a sha-bang line to indicate that this script is to be executed with Python:
#!/usr/bin/env python #
- Next, we'll need to import a couple of Python modules ...