- AnsibleFest
- Products
- Community
- Webinars & Training
- Blog

Documentation

# vmware_vm_inventory – VMware Guest inventory source

New in version 2.7.

- Synopsis
- Requirements
- Parameters
- Examples
- Status

## Synopsis

- Get virtual machines as inventory hosts from VMware environment.
- Uses any file which ends with vmware.yml or vmware.yaml as a YAML configuration file.
- The inventory_hostname is always the ‘Name’ and UUID of the virtual machine. UUID is added as VMware allows virtual machines with the same name.

## Requirements

The below requirements are needed on the local master node that executes this inventory.

- Python >= 2.7
- PyVmomi
- requests >= 2.3
- vSphere Automation SDK - For tag feature
- vCloud Suite SDK - For tag feature

## Parameters

Parameter | Choices/Defaults | Configuration | Comments
--- | --- | --- | ---
cache boolean | Choices: no ← yes | ini entries: [inventory] cache = no env:ANSIBLE_INVENTORY_CACHE | Toggle to enable/disable the caching of the inventory's source data, requires a cache plugin setup to work.
cache_connection string |  | ini entries: [defaults] fact_caching_connection = VALUE [inventory] cache_connection = VALUE env:ANSIBLE_CACHE_PLUGIN_CONNECTION env:ANSIBLE_INVENTORY_CACHE_CONNECTION | Cache connection data or path, read cache plugin documentation for specifics.
cache_plugin string | Default: "memory" | ini entries: [defaults] fact_caching = memory [inventory] cache_plugin = memory env:ANSIBLE_CACHE_PLUGIN env:ANSIBLE_INVENTORY_CACHE_PLUGIN | Cache plugin to use for the inventory's source data.
cache_prefix - | Default: "ansible_inventory_" | ini entries: [default] fact_caching_prefix = ansible_inventory_ [inventory] cache_prefix = ansible_inventory_ env:ANSIBLE_CACHE_PLUGIN_PREFIX env:ANSIBLE_INVENTORY_CACHE_PLUGIN_PREFIX | Prefix to use for cache plugin files/tables
cache_timeout integer | Default: 3600 | ini entries: [defaults] fact_caching_timeout = 3600 [inventory] cache_timeout = 3600 env:ANSIBLE_CACHE_PLUGIN_TIMEOUT env:ANSIBLE_INVENTORY_CACHE_TIMEOUT | Cache duration in seconds
hostname - / required |  | env:VMWARE_SERVER | Name of vCenter or ESXi server.
password - / required |  | env:VMWARE_PASSWORD | Password of vSphere admin user.
port - | Default: 443 | env:VMWARE_PORT | Port number used to connect to vCenter or ESXi Server.
properties list added in 2.9 | Default: ["name", "config.cpuHotAddEnabled", "config.cpuHotRemoveEnabled", "config.instanceUuid", "config.hardware.numCPU", "config.template", "config.name", "guest.hostName", "guest.ipAddress", "guest.guestId", "guest.guestState", "runtime.maxMemoryUsage", "customValue"] |  | Specify the list of VMware schema properties associated with the VM. These properties will be populated in hostvars of the given VM. Each value in the list specifies the path to a specific property in VM object.
username - / required |  | env:VMWARE_USERNAME | Name of vSphere admin user.
validate_certs boolean | Default: "yes" |  | Allows connection when SSL certificates are not valid. Set to `false` when certificates are not trusted.
with_tags boolean | Default: "no" |  | Include tags and associated virtual machines. Requires 'vSphere Automation SDK' library to be installed on the given controller machine. Please refer following URLs for installation steps https://code.vmware.com/web/sdk/65/vsphere-automation-python

## Examples

    # Sample configuration file for VMware Guest dynamic inventory
        plugin: vmware_vm_inventory
        strict: False
        hostname: 10.65.223.31
        username: administrator@vsphere.local
        password: Esxi@123$%
        validate_certs: False
        with_tags: True

    # Gather minimum set of properties for VMware guest
        plugin: vmware_vm_inventory
        strict: False
        hostname: 10.65.223.31
        username: administrator@vsphere.local
        password: Esxi@123$%
        validate_certs: False
        with_tags: False
        properties:
        - 'name'
        - 'guest.ipAddress'

## Status

- This inventory is not guaranteed to have a backwards compatible interface. [preview]
- This inventory is maintained by the Ansible Community. [community]

### Authors

- Abhijeet Kasurde (@Akasurde)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.