# Explain dynamic inventory

**URL:** <https://forum.ansible.com/t/explain-dynamic-inventory/29290>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [December 18, 2018, 5:16pm UTC](https://forum.ansible.com/t/explain-dynamic-inventory/29290 "2018-12-18T17:16:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jimmy\_Htor](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@Jimmy\_Htor](https://forum.ansible.com/u/Jimmy_Htor)\
**Post date:** [December 18, 2018, 5:16pm UTC](https://forum.ansible.com/t/explain-dynamic-inventory/29290/1 "2018-12-18T17:16:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jimmy\_Htor](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@Jimmy\_Htor](https://forum.ansible.com/u/Jimmy_Htor)\
**Post date:** [December 18, 2018, 6:33pm UTC](https://forum.ansible.com/t/explain-dynamic-inventory/29290/2 "2018-12-18T18:33:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 18, 2018, 7:26pm UTC](https://forum.ansible.com/t/explain-dynamic-inventory/29290/3 "2018-12-18T19:26:52Z")

</div>

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.
