community.vmware.vmware_host_inventory inventory – VMware ESXi hostsystem inventory source
Note
This inventory plugin is part of the community.vmware collection (version 4.8.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
.
You need further requirements to be able to use this inventory plugin,
see Requirements for details.
To use it in a playbook, specify: community.vmware.vmware_host_inventory
.
Synopsis
Get VMware ESXi hostsystem as inventory hosts from VMware environment.
Uses any file which ends with vmware.yml, vmware.yaml, vmware_host_inventory.yml, or vmware_host_inventory.yaml as a YAML configuration file.
Requirements
The below requirements are needed on the local controller node that executes this inventory.
vSphere Automation SDK - For tag feature
Parameters
Parameter |
Comments |
---|---|
Toggle to enable/disable the caching of the inventory’s source data, requires a cache plugin setup to work. Choices:
Configuration:
|
|
Cache connection data or path, read cache plugin documentation for specifics. Configuration:
|
|
Cache plugin to use for the inventory’s source data. Default: Configuration:
|
|
Prefix to use for cache plugin files/tables Default: Configuration:
|
|
Cache duration in seconds Default: Configuration:
|
|
Create vars from jinja2 expressions. Default: |
|
This option allows client-side filtering hosts with jinja templating. When server-side filtering is introduced, it should be preferred over this. Default: |
|
Add hosts to group based on Jinja2 conditionals. Default: |
|
Name of vCenter or ESXi server. Configuration:
|
|
A list of templates in order of precedence to compose inventory_hostname. Ignores template if resulted in an empty string or None value. You can use property specified in Default: |
|
Add hosts to group based on the values of a variable. Default: |
|
The default value when the host variable’s value is an empty string. This option is mutually exclusive with |
|
The key from input dictionary used to generate groups |
|
parent group for keyed group |
|
A keyed group name will start with this prefix Default: |
|
separator used to build the keyed group name Default: |
|
Set this option to This option is mutually exclusive with Choices:
|
|
Use in conjunction with keyed_groups. By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore. This is because the default prefix is “” and the default separator is “_”. Set this option to False to omit the leading underscore (or other separator) if no prefix is given. If the group name is derived from a mapping the separator is still used to concatenate the items. To not use a separator in the group name at all, set the separator for the keyed group to an empty string instead. Choices:
|
|
Password of vSphere user. Accepts vault encrypted variable. Accepts Jinja to template the value Configuration:
|
|
Port number used to connect to vCenter or ESXi Server. Default: Configuration:
|
|
Specify the list of VMware schema properties associated with the ESXi hostsystem. These properties will be populated in hostvars of the given ESXi hostsystem. Each value in the list can be a path to a specific property in hostsystem object or a path to a collection of hostsystem objects.
Please make sure that all the properties that are used in other parameters are included in this options. In addition to ESXi hostsystem’s properties, the following are special values Use Use Default: |
|
Address of a proxy that will receive all HTTPS requests and relay them. The format is a hostname or a IP. Configuration:
|
|
Port of the HTTP proxy that will receive all HTTPS requests and relay them. Configuration:
|
|
A list of resources to limit search scope. Each resource item is represented by exactly one Key name is based on snake case of a vim type name; e.g Default: |
|
If Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default. Choices:
|
|
Merge extra vars into the available variables for composition (highest precedence). Choices:
Configuration:
|
|
Name of vSphere user. Accepts vault encrypted variable. Accepts Jinja to template the value Configuration:
|
|
Allows connection when SSL certificates are not valid. Set to Choices:
Configuration:
|
|
This option transform flatten properties name to nested dictionary. Choices:
|
|
Include ESXi hostsystem’s path. Set this option to a string value to replace root name from ‘Datacenters’. Choices:
|
|
This option allows property name sanitization to create safe property names for use in Ansible. Also, transforms property name to snake case. Choices:
|
|
Include tags and associated hosts. 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/7.0/vsphere-automation-python Choices:
|
Examples
# Sample configuration file for VMware Host dynamic inventory
plugin: community.vmware.vmware_host_inventory
strict: false
hostname: 10.65.223.31
username: [email protected]
password: Esxi@123$%
validate_certs: false
with_tags: true
# Sample configuration file for VMware Guest dynamic inventory using Jinja to template the username and password.
plugin: community.vmware.vmware_host_inventory
strict: false
hostname: 10.65.223.31
username: '{{ (lookup("file","~/.config/vmware.yaml") | from_yaml).username }}'
password: '{{ (lookup("file","~/.config/vmware.yaml") | from_yaml).password }}'
validate_certs: false
with_tags: true
# Using compose
plugin: community.vmware.vmware_host_inventory
hostname: 10.65.223.31
username: [email protected]
password: Esxi@123$%
validate_certs: false
properties:
- name
- summary
- config.lockdownMode
compose:
ansible_user: "'root'"
ansible_connection: "'ssh'"