community.vmware.vmware_vm_info module – Return basic info pertaining to a VMware machine guest
Note
This module is part of the community.vmware collection (version 5.9.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.vmware.
To use it in a playbook, specify: community.vmware.vmware_vm_info.
Synopsis
- Return basic information pertaining to a vSphere or ESXi virtual machine guest. 
Parameters
| Parameter | Comments | 
|---|---|
| Specify a folder location of VMs to gather information from. Examples: folder: /ha-datacenter/vm folder: ha-datacenter/vm folder: /datacenter1/vm folder: datacenter1/vm folder: /datacenter1/vm/folder1 folder: datacenter1/vm/folder1 folder: /folder1/datacenter1/vm folder: folder1/datacenter1/vm folder: /folder1/datacenter1/vm/folder2 | |
| The hostname or IP address of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable  | |
| The password of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable  | |
| The port number of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable  Default:  | |
| Address of a proxy that will receive all HTTPS requests and relay them. The format is a hostname or a IP. If the value is not specified in the task, the value of environment variable  | |
| Port of the HTTP proxy that will receive all HTTPS requests and relay them. If the value is not specified in the task, the value of environment variable  | |
| Allocated storage in byte and memory in MB are shown if it set to True. Choices: 
 | |
| Attributes related to VM guest shown in information only when this is set  Choices: 
 | |
| Tags virtual machine’s cluster is shown if set to  Choices: 
 | |
| Tags virtual machine’s datacenter is shown if set to  Choices: 
 | |
| Tags virtual machine’s datastore is shown if set to  Choices: 
 | |
| Tags virtual machine’s ESXi host is shown if set to  Choices: 
 | |
| Show folders Choices: 
 | |
| Tags virtual machine’s mac address is shown if set to  Choices: 
 | |
| Tags virtual machine’s network is shown if set to  Choices: 
 | |
| Tags virtual machine’s resource pool is shown if set to  Choices: 
 | |
| Tags related to virtual machine are shown if set to  Choices: 
 | |
| The username of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable  | |
| Allows connection when SSL certificates are not valid. Set to  If the value is not specified in the task, the value of environment variable  Choices: 
 | |
| Name of the virtual machine to get related configurations information from. | |
| If set to  If set to  If set to  Choices: 
 | 
Notes
Note
- All modules requires API write access and hence is not supported on a free ESXi license. 
- All variables and VMware object names are case sensitive. 
Examples
- name: Gather all registered virtual machines
  community.vmware.vmware_vm_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
  delegate_to: localhost
  register: vm_info
- debug:
    var: vm_info.virtual_machines
- name: Gather one specific VM
  community.vmware.vmware_vm_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    vm_name: 'vm_name_as_per_vcenter'
  delegate_to: localhost
  register: vm_info
- debug:
    var: vm_info.virtual_machines
- name: Gather only registered virtual machine templates
  community.vmware.vmware_vm_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    vm_type: template
  delegate_to: localhost
  register: template_info
- debug:
    var: template_info.virtual_machines
- name: Gather only registered virtual machines
  community.vmware.vmware_vm_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    vm_type: vm
  delegate_to: localhost
  register: vm_info
- debug:
    var: vm_info.virtual_machines
- name: Get UUID from given VM Name
  block:
    - name: Get virtual machine info
      community.vmware.vmware_vm_info:
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        folder: "/datacenter/vm/folder"
      delegate_to: localhost
      register: vm_info
    - debug:
        msg: "{{ item.uuid }}"
      with_items:
        - "{{ vm_info.virtual_machines | community.general.json_query(query) }}"
      vars:
        query: "[?guest_name=='DC0_H0_VM0']"
- name: Get Tags from given VM Name
  block:
    - name: Get virtual machine info
      community.vmware.vmware_vm_info:
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        folder: "/datacenter/vm/folder"
      delegate_to: localhost
      register: vm_info
    - debug:
        msg: "{{ item.tags }}"
      with_items:
        - "{{ vm_info.virtual_machines | community.general.json_query(query) }}"
      vars:
        query: "[?guest_name=='DC0_H0_VM0']"
- name: Gather all VMs from a specific folder
  community.vmware.vmware_vm_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    folder: "/Asia-Datacenter1/vm/prod"
  delegate_to: localhost
  register: vm_info
- name: Get datastore_url from given VM name
  block:
    - name: Get virtual machine info
      community.vmware.vmware_vm_info:
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
      delegate_to: localhost
      register: vm_info
    - debug:
        msg: "{{ item.datastore_url }}"
      with_items:
        - "{{ vm_info.virtual_machines | community.general.json_query(query) }}"
      vars:
        query: "[?guest_name=='DC0_H0_VM0']"
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| list of dictionary of virtual machines and their information Returned: success Sample:  | 
