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.
Akasurde
(Abhijeet Kasurde)
December 4, 2019, 12:20pm
2
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
Thank you Abhikeet for the quick response, Will take a look into it.
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:
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