Questions regarding inventory plugins

Hi folks,

Following #44721[1], I've been investigating how to write a Linode
inventory plugin. Along with the questions in that ticket (happy if
anyone can help answer!) I have some more general questions:

* What is the return value of inventory plugins? They all seem to be different.
  Is there some standard format? For example, a JSON response format.

* Is there are best practice for writing these plugins? Looking at the
  plugin list[1], they all seem to take different approaches with
  filters, groups and querying parameters.

My assumption is that I should try to mimic what the cloud provider
exposes. So, in the case of Linode, as the existing Linode inventory
script does, we expose linode IDs, datacenter IDs and group names, etc.
This some how feels quite ad-hoc and perhaps confusing to users who will
use inventory plugins ('what do I actually get from this plugin to
target!?').

Here's all the documentation I can find right now:

https://docs.ansible.com/ansible/latest/plugins/inventory.html

I'd like to improve this, if possible, with the following discussion.

Thanks,

Luke

[1]: https://github.com/ansible/ansible/issues/44721
[2]: https://docs.ansible.com/ansible/latest/plugins/inventory.html#plugin-list

There is an open PR to provide a little more documentation for users converting an inventory script to an inventory plugin:

https://github.com/ansible/ansible/pull/44727

That might be of use (Note: I haven’t yet read through the changes)

To clarify, unlike inventory scripts, inventory plugins don't 'return'
a format, they update the inventory itself.

Thanks to you both! That documentation PR is certainly helpful, I think
I have enough to push forward writing that inventory plugin now :slight_smile:

To update, this inventory plugin arrived!

Please consider using it vs. the old Linode inventory script.

https://github.com/ansible/ansible/pull/45902

Will be released in 2.8, now in `devel`.

Best,

Luke