Documentation

vmware_vm_inventory – VMware Guest inventory source

New in version 2.7.

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.
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' and 'vCloud Suite SDK' libraries 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
https://code.vmware.com/web/sdk/60/vcloudsuite-python

Examples

# Sample configuration file for VMware Guest dynamic inventory
    plugin: vmware_vm_inventory
    strict: False
    hostname: 10.65.223.31
    username: [email protected]
    password: [email protected]$%
    validate_certs: False
    with_tags: True

Status

Authors

  • Abhijeet Kasurde (@Akasurde)

Hint

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