Gather List of VMs running on vmware esxi host

1,882 views
Skip to first unread message

Ahamed Fazlul Wahab

unread,
Dec 4, 2019, 6:55:36 AM12/4/19
to Ansible Project
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.

Abhijeet Kasurde

unread,
Dec 4, 2019, 7:20:34 AM12/4/19
to ansible...@googlegroups.com
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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4de33f79-4d92-4887-98ae-af09d83d65dc%40googlegroups.com.


--
Thanks,
Abhijeet Kasurde

Ahamed Fazlul Wahab

unread,
Dec 4, 2019, 7:28:02 AM12/4/19
to Ansible Project
Thank you Abhikeet for the quick response, Will take a look into it. 



On Wednesday, December 4, 2019 at 8:20:34 PM UTC+8, Abhijeet Kasurde wrote:
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

On Wed, Dec 4, 2019 at 5:25 PM Ahamed Fazlul Wahab <afws...@gmail.com> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.


--
Thanks,
Abhijeet Kasurde

alicia

unread,
Dec 5, 2019, 12:52:38 PM12/5/19
to ansible...@googlegroups.com
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

Once you have the VMs in inventory, you can use the VMware guest info module to retrieve information about the individual VMs:

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

Hope this helps,
Alicia

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages