vsphere_storage_drs_vm_override
The vsphere_storage_drs_vm_override
resource can be used to add a Storage DRS override to a datastore cluster for a specific virtual machine. With this resource, one can enable or disable Storage DRS, and control the automation level and disk affinity for a single virtual machine without affecting the rest of the datastore cluster.
For more information on vSphere datastore clusters and Storage DRS, see this page.
Example Usage
The example below builds on the Storage DRS example in the vsphere_virtual_machine
resource. However, rather than use the output of the vsphere_datastore_cluster
data source for the location of the virtual machine, we instead get what is assumed to be a member datastore using the vsphere_datastore
data source and put the virtual machine there instead. We then use the vsphere_storage_drs_vm_override
resource to ensure that Storage DRS does not apply to this virtual machine, and hence the VM will never be migrated off of the datastore.
data "vsphere_datacenter" "dc" { name = "dc1" } data "vsphere_datastore_cluster" "datastore_cluster" { name = "datastore-cluster1" datacenter_id = "${data.vsphere_datacenter.dc.id}" } data "vsphere_datastore" "member_datastore" { name = "datastore-cluster1-member1" datacenter_id = "${data.vsphere_datacenter.dc.id}" } data "vsphere_resource_pool" "pool" { name = "cluster1/Resources" datacenter_id = "${data.vsphere_datacenter.dc.id}" } data "vsphere_network" "network" { name = "public" datacenter_id = "${data.vsphere_datacenter.dc.id}" } resource "vsphere_virtual_machine" "vm" { name = "terraform-test" resource_pool_id = "${data.vsphere_resource_pool.pool.id}" datastore_id = "${data.vsphere_datastore.member_datastore.id}" num_cpus = 2 memory = 1024 guest_id = "other3xLinux64Guest" network_interface { network_id = "${data.vsphere_network.network.id}" } disk { label = "disk0" size = 20 } } resource "vsphere_storage_drs_vm_override" "drs_vm_override" { datastore_cluster_id = "${data.vsphere_datastore_cluster.datastore_cluster.id}" virtual_machine_id = "${vsphere_virtual_machine.vm.id}" sdrs_enabled = false }
Argument Reference
The following arguments are supported:
-
datastore_cluster_id
- (Required) The managed object reference ID of the datastore 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. -
sdrs_enabled
- (Optional) Overrides the default Storage DRS setting for this virtual machine. When not specified, the datastore cluster setting is used. -
sdrs_automation_level
- (Optional) Overrides any Storage DRS automation levels for this virtual machine. Can be one ofautomated
ormanual
. When not specified, the datastore cluster's settings are used according to the specific SDRS subsystem. -
sdrs_intra_vm_affinity
- (Optional) Overrides the intra-VM affinity setting for this virtual machine. Whentrue
, all disks for this virtual machine will be kept on the same datastore. Whenfalse
, Storage DRS may locate individual disks on different datastores if it helps satisfy cluster requirements. When not specified, the datastore cluster's settings are used.
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 datastore 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 datastore 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_storage_drs_vm_override.drs_vm_override \ '{"datastore_cluster_path": "/dc1/datastore/ds-cluster", \ "virtual_machine_path": "/dc1/vm/srv1"}'
© 2018 HashiCorpLicensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/vsphere/r/storage_drs_vm_override.html