In Chapter 1, Getting Started with Ansible, we saw how Ansible needs an inventory file, so that it knows where its hosts are and how to access them. Ansible also allows you to specify a script that allows you to fetch the inventory from another source. External inventory scripts can be written in any language that you like as long as they output valid JSON.
An external inventory script has to accept two different calls from Ansible. If called with
–list, it must return a list of all the available groups and hosts. Additionally, it may be called with
--host. In this case, the second argument will be a hostname and the script is expected to return a list of variables for that host. All the outputs are expected in JSON, so you ...