# Gather List of VMs running on vmware esxi host

**URL:** <https://forum.ansible.com/t/gather-list-of-vms-running-on-vmware-esxi-host/31758>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [December 4, 2019, 11:55am UTC](https://forum.ansible.com/t/gather-list-of-vms-running-on-vmware-esxi-host/31758 "2019-12-04T11:55:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahamed\_Fazlul\_Wahab](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Ahamed\_Fazlul\_Wahab](https://forum.ansible.com/u/Ahamed_Fazlul_Wahab)\
**Post date:** [December 4, 2019, 11:55am UTC](https://forum.ansible.com/t/gather-list-of-vms-running-on-vmware-esxi-host/31758/1 "2019-12-04T11:55:36Z")

</div>

Hi All,

I’m quite new to ansible, so apologies if I’m asking an obvious question.

Is it possible for any ansible vmware module to fetch the list of VMs running on a particular vmware esxi host. Also we need to extract certain VM information of each VM (OS type, OS version, hostname., IP)

Could this be done ? If yes, could someone tell me which module to use.

Appreciate you help on this. Thank you.

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [December 4, 2019, 12:20pm UTC](https://forum.ansible.com/t/gather-list-of-vms-running-on-vmware-esxi-host/31758/2 "2019-12-04T12:20:01Z")

</div>

Hi,

You can take a look at `vmware_vm_info` module, it will return details about all VMs, Templates in the given folder. Here is basic example -

- name: Gather all registered virtual machines  
vmware\_vm\_info:  
hostname: ‘{{ vcenter\_hostname }}’  
username: ‘{{ vcenter\_username }}’  
password: ‘{{ vcenter\_password }}’  
delegate\_to: localhost  
register: vminfo

- debug:  
var: vminfo.virtual\_machines

---

<div class="post-metadata">

**Author:** ![Ahamed\_Fazlul\_Wahab](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Ahamed\_Fazlul\_Wahab](https://forum.ansible.com/u/Ahamed_Fazlul_Wahab)\
**Post date:** [December 4, 2019, 12:28pm UTC](https://forum.ansible.com/t/gather-list-of-vms-running-on-vmware-esxi-host/31758/3 "2019-12-04T12:28:02Z")

</div>

Thank you Abhikeet for the quick response, Will take a look into it.

---

<div class="post-metadata">

**Author:** ![acozine1](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@acozine1](https://forum.ansible.com/u/acozine1)\
**Post date:** [December 5, 2019, 5:52pm UTC](https://forum.ansible.com/t/gather-list-of-vms-running-on-vmware-esxi-host/31758/4 "2019-12-05T17:52:21Z")

</div>

The VMware dynamic inventory plugin will track your running VMs, creating and updating an inventory (or list) of all VMs running in VMware: [https://docs.ansible.com/ansible/latest/scenario\_guides/vmware\_scenarios/vmware\_inventory.html](https://docs.ansible.com/ansible/latest/scenario_guides/vmware_scenarios/vmware_inventory.html)

Once you have the VMs in inventory, you can use the VMware guest info module to retrieve information about the individual VMs:  
[https://docs.ansible.com/ansible/latest/modules/vmware\_guest\_info\_module.html#vmware-guest-info-module](https://docs.ansible.com/ansible/latest/modules/vmware_guest_info_module.html#vmware-guest-info-module)

You can also reach out to the working group for VMware on Freenode IRC - the channel is #ansible-vmware.

Hope this helps,  
Alicia
