community.vmware.vmware_host module – Add, remove, or move an ESXi host to, from, or within vCenter
Note
This module is part of the community.vmware collection (version 4.7.1).
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_host
.
Synopsis
This module can be used to add, reconnect, or remove an ESXi host to or from vCenter.
This module can also be used to move an ESXi host to a cluster or folder, or vice versa, within the same datacenter.
Parameters
Parameter |
Comments |
---|---|
If set to This parameter is ignored if not Choices:
|
|
Name of the cluster to add the host. If |
|
Name of the datacenter to add the host. |
|
ESXi hostname to manage. |
|
ESXi password. Required for adding a host. Optional for reconnect. Unused for removing. No longer a required parameter from version 2.5. |
|
Specifying the hostsystem certificate’s thumbprint. Use following command to get hostsystem certificate’s thumbprint - # openssl x509 -in /etc/vmware/ssl/rui.crt -fingerprint -sha1 -noout Default: |
|
ESXi username. Required for adding a host. Optional for reconnect. If both Unused for removing. No longer a required parameter from version 2.5. |
|
Fetch the thumbprint of the host’s SSL certificate. This basically disables the host certificate verification (check if it was signed by a recognized CA). Disable this option if you want to allow only hosts with valid certificates to be added to vCenter. If this option is set to Unused when Optional for reconnect, but only used if Unused for removing. Choices:
|
|
Name of the folder under which host to add. If For example, if there is a datacenter ‘dc1’ under folder called ‘Site1’ then, this value will be ‘/Site1/dc1/host’. Here ‘host’ is an invisible folder under VMware Web Client. Another example, if there is a nested folder structure like ‘/myhosts/india/pune’ under datacenter ‘dc2’, then Other Examples: ‘/Site2/dc2/Asia-Cluster/host’ or ‘/dc3/Asia-Cluster/host’ |
|
Force the connection if the host is already being managed by another vCenter server. Choices:
|
|
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 |
|
Reconnect disconnected hosts. This is only used if Choices:
|
|
If set to If set to If set to If set to If set to If set to 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:
|
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: Add ESXi Host to vCenter
community.vmware.vmware_host:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: datacenter_name
cluster: cluster_name
esxi_hostname: '{{ esxi_hostname }}'
esxi_username: '{{ esxi_username }}'
esxi_password: '{{ esxi_password }}'
state: present
delegate_to: localhost
- name: Add ESXi Host to vCenter under a specific folder
community.vmware.vmware_host:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: datacenter_name
folder: '/Site2/Asia-Cluster/host'
esxi_hostname: '{{ esxi_hostname }}'
esxi_username: '{{ esxi_username }}'
esxi_password: '{{ esxi_password }}'
state: present
add_connected: true
delegate_to: localhost
- name: Reconnect ESXi Host (with username/password set)
community.vmware.vmware_host:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: datacenter_name
cluster: cluster_name
esxi_hostname: '{{ esxi_hostname }}'
esxi_username: '{{ esxi_username }}'
esxi_password: '{{ esxi_password }}'
state: reconnect
delegate_to: localhost
- name: Reconnect ESXi Host (with default username/password)
community.vmware.vmware_host:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: datacenter_name
cluster: cluster_name
esxi_hostname: '{{ esxi_hostname }}'
state: reconnect
delegate_to: localhost
- name: Add ESXi Host with SSL Thumbprint to vCenter
community.vmware.vmware_host:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: datacenter_name
cluster: cluster_name
esxi_hostname: '{{ esxi_hostname }}'
esxi_username: '{{ esxi_username }}'
esxi_password: '{{ esxi_password }}'
esxi_ssl_thumbprint: "3C:A5:60:6F:7A:B7:C4:6C:48:28:3D:2F:A5:EC:A3:58:13:88:F6:DD"
state: present
delegate_to: localhost
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
metadata about the new host system added Returned: on successful addition Sample: |