Hey all,
In my workflow at work, we us Ansible for managing dynamically provisioned Azure VMs after they’re provisioned. Currently our provisioning scripts setup the Azure VMs, and then generate an ansible inventory file, which we store in AWS S3. This way, any of the operations folks who want to run post provisioning playbooks, they go download the inventory file from AWS S3, and then run the playbooks using the regular syntax ansible-playbook a-playbook.yml -i path/to/downloaded/inventory/file
.
We recently upgraded to Ansible 2.4, and was wondering, that given the new inventory plugin refactor, if it would be possible for me to write a plugin, that wraps the INI plugin, but does the automatic download of the inventory from the AWS S3 source. How would I go about doing it? Specifically…
- Can I write my custom inventory plugin in my
lib/
directory, and Ansible will pick it up? Or is there another path where it looks for inventory plugins. - Is there any documentation on writing a custom plugin, including the interface of expected method calls and return values?
- Bonus, does the current design allow me to “compose” (in the sense of functional programming) plugins over existing plugins?
So for example in my case, I would just add a wrapper plugin class (or maybe a child class of the INI plugin), and add the logic to download the inventory file. Specifically something that would work with the command line ansible-playbook my-playbook.yml -i s3://my-bucket/inventory/path
.
Thanks in advance,
Archit
P.S. Note the basic idea I’m going for is not really an Inventory plugin,as much as writing an inventory lookup plugin.