title: Custom dynamic inventory scripts/plugins in Ansible
body: <p><a href="http://docs.ansible.com/ansible/developing_inventory.html" rel="nofollow">Ansible allows devs</a>
   to write programs (in any language) that will return JSON describing the dynamic “snapshot” of current hosts. I’m using vSphere, which is currently not supported by Ansible OSS, and so I need to write such a "<em>custom inventory plugin</em>".</p>
  
  <p>I can handle the querying of vSphere for a list of hosts, as well as constructing the JSON that is compatible with what Ansible is expecting.</p>
  
  <p>Where the documentation completely (seemingly) falls flat is:</p>
  
  <ul>
  <li>How do I “connect” Ansible with my inventory app? That is, say my inventory app is a simple bash script (<code>inventory.sh</code>)..how do I configure Ansible to call <code>bash inventory.sh</code> and obtain JSON from it? In reality the app will likely be a Java executable (<code>inventory.jar</code>) but I figure that if I can figure out how to get it working with bash, I can extrapolate to Java; and</li>
  <li>How does Ansible actually capture/fetch the JSON back from the app? <code>STDOUT</code>? Is this all supposed to happen over an HTTP connection? Examples? How does <code>inventory.sh</code> or <code>inventory.jar</code> communicate that JSON back to Ansible?</li>
  </ul>