vmware_cluster – Manage VMware vSphere clusters — Ansible Documentation

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

Documentation

# vmware_cluster – Manage VMware vSphere clusters

- Synopsis
- Requirements
- Parameters
- See Also
- Examples
- Status

## Synopsis

- Adds or removes VMware vSphere clusters.
- Although this module can manage DRS, HA and VSAN related configurations, this functionality is deprecated and will be removed in 2.12.
- To manage DRS, HA and VSAN related configurations, use the new modules vmware_cluster_drs, vmware_cluster_ha and vmware_cluster_vsan.
- All values and VMware object names are case sensitive.

## Requirements

The below requirements are needed on the host that executes this module.

- Tested on ESXi 5.5 and 6.5.
- PyVmomi installed.

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
cluster_name string / required |  | The name of the cluster to be managed.
datacenter string / required |  | The name of the datacenter. aliases: datacenter_name
drs_default_vm_behavior - added in 2.8 | Choices: fullyAutomated ← manual partiallyAutomated | Specifies the cluster-wide default DRS behavior for virtual machines. If set to `partiallyAutomated`, then vCenter generate recommendations for virtual machine migration and for the placement with a host. vCenter automatically implement placement at power on. If set to `manual`, then vCenter generate recommendations for virtual machine migration and for the placement with a host. vCenter should not implement the recommendations automatically. If set to `fullyAutomated`, then vCenter should automate both the migration of virtual machines and their placement with a host at power on. Use `drs_default_vm_behavior` of vmware_cluster_drs instead. Deprecated option, will be removed in version 2.12.
drs_enable_vm_behavior_overrides boolean added in 2.8 | Choices: no yes ← | Determines whether DRS Behavior overrides for individual virtual machines are enabled. If set to `True`, overrides `drs_default_vm_behavior`. Use `drs_enable_vm_behavior_overrides` of vmware_cluster_drs instead. Deprecated option, will be removed in version 2.12.
drs_vmotion_rate - added in 2.8 | Choices: 1 2 3 ← 4 5 | Threshold for generated ClusterRecommendations. Use `drs_vmotion_rate` of vmware_cluster_drs instead. Deprecated option, will be removed in version 2.12.
enable_drs boolean | Choices: no ← yes | If set to `yes`, will enable DRS when the cluster is created. Use `enable_drs` of vmware_cluster_drs instead. Deprecated option, will be removed in version 2.12.
enable_ha boolean | Choices: no ← yes | If set to `yes` will enable HA when the cluster is created. Use `enable_ha` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
enable_vsan boolean | Choices: no ← yes | If set to `yes` will enable vSAN when the cluster is created. Use `enable_vsan` of vmware_cluster_vsan instead. Deprecated option, will be removed in version 2.12.
ha_admission_control_enabled boolean added in 2.8 | Choices: no yes ← | Determines if strict admission control is enabled. It is recommended to set this parameter to `True`, please refer documentation for more details. Use `slot_based_admission_control`, `reservation_based_admission_control` or `failover_host_admission_control` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
ha_failover_level - added in 2.8 | Default: 2 | Number of host failures that should be tolerated, still guaranteeing sufficient resources to restart virtual machines on available hosts. Accepts integer values only. Use `slot_based_admission_control`, `reservation_based_admission_control` or `failover_host_admission_control` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
ha_host_monitoring - added in 2.8 | Choices: enabled ← disabled | Indicates whether HA restarts virtual machines after a host fails. If set to `enabled`, HA restarts virtual machines after a host fails. If set to `disabled`, HA does not restart virtual machines after a host fails. If `enable_ha` is set to `no`, then this value is ignored. Use `ha_host_monitoring` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
ha_restart_priority - added in 2.8 | Choices: disabled high low medium ← | Determines the preference that HA gives to a virtual machine if sufficient capacity is not available to power on all failed virtual machines. This setting is only valid if `ha_vm_monitoring` is set to, either `vmAndAppMonitoring` or `vmMonitoringOnly`. If set to `disabled`, then HA is disabled for this virtual machine. If set to `high`, then virtual machine with this priority have a higher chance of powering on after a failure, when there is insufficient capacity on hosts to meet all virtual machine needs. If set to `medium`, then virtual machine with this priority have an intermediate chance of powering on after a failure, when there is insufficient capacity on hosts to meet all virtual machine needs. If set to `low`, then virtual machine with this priority have a lower chance of powering on after a failure, when there is insufficient capacity on hosts to meet all virtual machine needs. Use `ha_restart_priority` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
ha_vm_failure_interval - added in 2.8 | Default: 30 | The number of seconds after which virtual machine is declared as failed if no heartbeat has been received. This setting is only valid if `ha_vm_monitoring` is set to, either `vmAndAppMonitoring` or `vmMonitoringOnly`. Unit is seconds. Use `ha_vm_failure_interval` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
ha_vm_max_failure_window - added in 2.8 | Default: -1 | The number of seconds for the window during which up to `ha_vm_max_failures` resets can occur before automated responses stop. This setting is only valid if `ha_vm_monitoring` is set to, either `vmAndAppMonitoring` or `vmMonitoringOnly`. Unit is seconds. Default specifies no failure window. Use `ha_vm_max_failure_window` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
ha_vm_max_failures - added in 2.8 | Default: 3 | Maximum number of failures and automated resets allowed during the time that `ha_vm_max_failure_window` specifies. This setting is only valid if `ha_vm_monitoring` is set to, either `vmAndAppMonitoring` or `vmMonitoringOnly`. Use `ha_vm_max_failures` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
ha_vm_min_up_time - added in 2.8 | Default: 120 | The number of seconds for the virtual machine's heartbeats to stabilize after the virtual machine has been powered on. This setting is only valid if `ha_vm_monitoring` is set to, either `vmAndAppMonitoring` or `vmMonitoringOnly`. Unit is seconds. Use `ha_vm_min_up_time` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
ha_vm_monitoring - added in 2.8 | Choices: vmAndAppMonitoring vmMonitoringOnly vmMonitoringDisabled ← | Indicates the state of virtual machine health monitoring service. If set to `vmAndAppMonitoring`, HA response to both virtual machine and application heartbeat failure. If set to `vmMonitoringDisabled`, virtual machine health monitoring is disabled. If set to `vmMonitoringOnly`, HA response to virtual machine heartbeat failure. If `enable_ha` is set to `no`, then this value is ignored. Use `ha_vm_monitoring` of vmware_cluster_ha instead. Deprecated option, will be removed in version 2.12.
hostname string |  | 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 `VMWARE_HOST` will be used instead. Environment variable support added in Ansible 2.6.
ignore_drs boolean added in 2.9 | Choices: no ← yes | If set to `yes`, DRS will not be configured; all explicit and default DRS related configurations will be ignored.
ignore_ha boolean added in 2.9 | Choices: no ← yes | If set to `yes`, HA will not be configured; all explicit and default HA related configurations will be ignored.
ignore_vsan boolean added in 2.9 | Choices: no ← yes | If set to `yes`, VSAN will not be configured; all explicit and default VSAN related configurations will be ignored.
password string |  | The password of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable `VMWARE_PASSWORD` will be used instead. Environment variable support added in Ansible 2.6. aliases: pass, pwd
port integer added in 2.5 | Default: 443 | The port number of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable `VMWARE_PORT` will be used instead. Environment variable support added in Ansible 2.6.
proxy_host string added in 2.9 |  | 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 `VMWARE_PROXY_HOST` will be used instead. This feature depends on a version of pyvmomi greater than v6.7.1.2018.12
proxy_port integer added in 2.9 |  | 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 `VMWARE_PROXY_PORT` will be used instead.
state - | Choices: absent present ← | Create `present` or remove `absent` a VMware vSphere cluster.
username string |  | The username of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable `VMWARE_USER` will be used instead. Environment variable support added in Ansible 2.6. aliases: admin, user
validate_certs boolean | Choices: no yes ← | Allows connection when SSL certificates are not valid. Set to `false` when certificates are not trusted. If the value is not specified in the task, the value of environment variable `VMWARE_VALIDATE_CERTS` will be used instead. Environment variable support added in Ansible 2.6. If set to `yes`, please make sure Python >= 2.7.9 is installed on the given machine.
vsan_auto_claim_storage boolean added in 2.8 | Choices: no ← yes | Determines whether the VSAN service is configured to automatically claim local storage on VSAN-enabled hosts in the cluster. Use `vsan_auto_claim_storage` of vmware_cluster_vsan instead. Deprecated option, will be removed in version 2.12.

## See Also

See also

vmware_cluster_drs – Manage Distributed Resource Scheduler (DRS) on VMware vSphere clusters
  The official documentation on the vmware_cluster_drs module.
vmware_cluster_ha – Manage High Availability (HA) on VMware vSphere clusters
  The official documentation on the vmware_cluster_ha module.
vmware_cluster_vsan – Manages virtual storage area network (vSAN) configuration on VMware vSphere clusters
  The official documentation on the vmware_cluster_vsan module.

## Examples

    - name: Create Cluster
      vmware_cluster:
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        datacenter_name: datacenter
        cluster_name: cluster
        enable_ha: yes
        enable_drs: yes
        enable_vsan: yes
      delegate_to: localhost

    - name: Create Cluster with additional changes
      vmware_cluster:
        hostname: "{{ vcenter_server }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_pass }}"
        validate_certs: no
        datacenter_name: DC0
        cluster_name: "{{ cluster_name }}"
        enable_ha: True
        ha_vm_monitoring: vmMonitoringOnly
        enable_drs: True
        drs_default_vm_behavior: partiallyAutomated
        enable_vsan: True
      register: cl_result
      delegate_to: localhost

    - name: Delete Cluster
      vmware_cluster:
        hostname: "{{ vcenter_server }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_pass }}"
        datacenter_name: datacenter
        cluster_name: cluster
        enable_ha: yes
        enable_drs: yes
        enable_vsan: yes
        state: absent

## Status

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

### Authors

- Joseph Callen (@jcpowermac)
- Abhijeet Kasurde (@Akasurde)

Hint

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