vsphere_ha_vm_override
The vsphere_ha_vm_override
resource can be used to add an override for vSphere HA settings on a cluster for a specific virtual machine. With this resource, one can control specific HA settings so that they are different than the cluster default, accommodating the needs of that specific virtual machine, while not affecting the rest of the cluster.
For more information on vSphere HA, see this page.
NOTE: This resource requires vCenter and is not available on direct ESXi connections.
Example Usage
The example below creates a virtual machine in a cluster using the vsphere_virtual_machine
resource, creating the virtual machine in the cluster looked up by the vsphere_compute_cluster
data source.
Considering a scenario where this virtual machine is of high value to the application or organization for which it does its work, it's been determined in the event of a host failure, that this should be one of the first virtual machines to be started by vSphere HA during recovery. Hence, its ha_vm_restart_priority
as been set to highest
, which, assuming that the default restart priority is medium
and no other virtual machine has been assigned the highest
priority, will mean that this VM will be started before any other virtual machine in the event of host failure.
data "vsphere_datacenter" "dc" { name = "dc1" } data "vsphere_datastore" "datastore" { name = "datastore1" datacenter_id = "${data.vsphere_datacenter.dc.id}" } data "vsphere_compute_cluster" "cluster" { name = "cluster1" datacenter_id = "${data.vsphere_datacenter.dc.id}" } data "vsphere_network" "network" { name = "network1" datacenter_id = "${data.vsphere_datacenter.dc.id}" } resource "vsphere_virtual_machine" "vm" { name = "terraform-test" resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}" datastore_id = "${data.vsphere_datastore.datastore.id}" num_cpus = 2 memory = 2048 guest_id = "other3xLinux64Guest" network_interface { network_id = "${data.vsphere_network.network.id}" } disk { label = "disk0" size = 20 } } resource "vsphere_ha_vm_override" "ha_vm_override" { compute_cluster_id = "${data.vsphere_compute_cluster.cluster.id}" virtual_machine_id = "${vsphere_virtual_machine.vm.id}" ha_vm_restart_priority = "highest" }
Argument Reference
The following arguments are supported:
General Options
The following options are required:
-
compute_cluster_id
- (Required) The managed object reference ID of the cluster to put the override in. Forces a new resource if changed. -
virtual_machine_id
- (Required) The UUID of the virtual machine to create the override for. Forces a new resource if changed.
vSphere HA Options
The following settings work nearly in the same fashion as their counterparts in the vsphere_compute_cluster
resource, with the exception that some options also allow settings that denote the use of cluster defaults. See the individual settings below for more details.
NOTE: The same version restrictions that apply for certain options within
vsphere_compute_cluster
apply to overrides as well. See here for an entire list of version restrictions.
General HA options
-
ha_vm_restart_priority
- (Optional) The restart priority for the virtual machine when vSphere detects a host failure. Can be one ofclusterRestartPriority
,lowest
,low
,medium
,high
, orhighest
. Default:clusterRestartPriority
. -
ha_vm_restart_timeout
- (Optional) The maximum time, in seconds, that vSphere HA will wait for this virtual machine to be ready. Use-1
to specify the cluster default. Default:-1
. * -
ha_host_isolation_response
- (Optional) The action to take on this virtual machine when a host has detected that it has been isolated from the rest of the cluster. Can be one ofclusterIsolationResponse
,none
,powerOff
, orshutdown
. Default:clusterIsolationResponse
.
HA Virtual Machine Component Protection settings
The following settings control Virtual Machine Component Protection (VMCP) overrides.
-
ha_datastore_pdl_response
- (Optional) Controls the action to take on this virtual machine when the cluster has detected a permanent device loss to a relevant datastore. Can be one ofclusterDefault
,disabled
,warning
, orrestartAggressive
. Default:clusterDefault
. * -
ha_datastore_apd_response
- (Optional) Controls the action to take on this virtual machine when the cluster has detected loss to all paths to a relevant datastore. Can be one ofclusterDefault
,disabled
,warning
,restartConservative
, orrestartAggressive
. Default:clusterDefault
. * -
ha_datastore_apd_recovery_action
- (Optional) Controls the action to take on this virtual machine if an APD status on an affected datastore clears in the middle of an APD event. Can be one ofuseClusterDefault
,none
orreset
. Default:useClusterDefault
. * -
ha_datastore_apd_response_delay
- (Optional) Controls the delay in minutes to wait after an APD timeout event to execute the response action defined inha_datastore_apd_response
. Use-1
to use the cluster default. Default:-1
. *
HA virtual machine and application monitoring settings
The following settings control virtual machine and application monitoring overrides.
Take note of the
ha_vm_monitoring_use_cluster_defaults
setting - this is defaulted totrue
and means that override settings are not used. Set this tofalse
to ensure your overrides function. Note that unlike the rest of the options in this resource, there are no granular per-setting cluster default values -ha_vm_monitoring_use_cluster_defaults
is the only toggle available.
-
ha_vm_monitoring_use_cluster_defaults
- (Optional) Determines whether or not the cluster's default settings or the VM override settings specified in this resource are used for virtual machine monitoring. The default istrue
(use cluster defaults) - set tofalse
to have overrides take effect. -
ha_vm_monitoring
- (Optional) The type of virtual machine monitoring to use when HA is enabled in the cluster. Can be one ofvmMonitoringDisabled
,vmMonitoringOnly
, orvmAndAppMonitoring
. Default:vmMonitoringDisabled
. -
ha_vm_failure_interval
- (Optional) If a heartbeat from this virtual machine is not received within this configured interval, the virtual machine is marked as failed. The value is in seconds. Default:30
. -
ha_vm_minimum_uptime
- (Optional) The time, in seconds, that HA waits after powering on this virtual machine before monitoring for heartbeats. Default:120
(2 minutes). -
ha_vm_maximum_resets
- (Optional) The maximum number of resets that HA will perform to this virtual machine when responding to a failure event. Default:3
-
ha_vm_maximum_failure_window
- (Optional) The length of the reset window in whichha_vm_maximum_resets
can operate. When this window expires, no more resets are attempted regardless of the setting configured inha_vm_maximum_resets
.-1
means no window, meaning an unlimited reset time is allotted. The value is specified in seconds. Default:-1
(no window).
Attribute Reference
The only attribute this resource exports is the id
of the resource, which is a combination of the managed object reference ID of the cluster, and the UUID of the virtual machine. This is used to look up the override on subsequent plan and apply operations after the override has been created.
Importing
An existing override can be imported into this resource by supplying both the path to the cluster, and the path to the virtual machine, to terraform import
. If no override exists, an error will be given. An example is below:
terraform import vsphere_ha_vm_override.ha_vm_override \ '{"compute_cluster_path": "/dc1/host/cluster1", \ "virtual_machine_path": "/dc1/vm/srv1"}'
© 2018 HashiCorpLicensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/vsphere/r/ha_vm_override.html