The vmware_vm_facts module

This module can be used to gather facts on either virtual machines or templates which are running in your VMware vSphere cluster:

- name: Gather facts on all VMs in the cluster  vmware_vm_facts:    hostname: "{{ vsphere_host }}"    username: "{{ vsphere_username }}"    password: "{{ vsphere_password }}"    vm_type: "vm"  delegate_to: "localhost"  register: vm_facts

The previous example gathers information on just the virtual machines that have been created with our cluster and registers the results as the vm_facts variable. If we wanted to find information on just the templates, we could update vm_type to template, or we could list all virtual machines and templates by updating vm_type to all.

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.