Explain dynamic inventory

Hey,

I don’t get how dynamic inventory is actually working. Or in my case, why it’s working.

So I’ve tried setting up the vmware_vm_inventory plugin.

I’ve put a vcenter.yml into /etc/ansible and “ansible-inventory -i /etc/ansible/ --list” is indeed giving me a list of all statically defined hosts plus those from vcenter.

  1. vcenter.yml is not ending with “vmware.yml” or “vmware.yaml” as the plugin claims it would need. However the command above still works.

  2. There is nothing executable inside /etc/ansible which apparently is needed to use dynamic inventory.

  3. When I use “ansible-inventory --list” (without -i) it’s only giving me the statically defined hosts.

I’d like to understand how this is all tied together. The documentation was not satisfactory on that point.

Is this set up correctly?

Thanks

Marki

I found out what 3) is about. You have to change the default inventory= in ansible.cfg to the directory (just like you specify the directory on the command line) duh

Still wondering about items 1) and 2) though.

1) no clue, that would not work with the plugin Ansible ships with
(just tested and vmware plugin skips that file)

2) you are confusing inventory plugins and inventory scripts, the
plugins require a 'source', one of the plugins is the 'script' plugin,
which uses 'inventory scripts' ... these need to be executable for the
'script' plugin to use.
So executable bit depends on what the inventory plugin requires,
script is the only one that ships with Ansible that requires this.

3) yeah, /etc/ansible/hosts is the default, so if no -i is supplied,
that will be used

when using -i /direcotry/ all the files in the directory will be
looked at for execution, each file will be passed to each active
inventory plugin and the plugin will decide if it takes the file
(needs to meet certain criteria) or passes, if it takes the file it
will attempt to parse it, if it fails, the next plugin will try.