vsphere_virtual_machine
The vsphere_virtual_machine data source can be used to find the UUID of an existing virtual machine or template. Its most relevant purpose is for finding the UUID of a template to be used as the source for cloning into a new vsphere_virtual_machine resource. It also reads the guest ID so that can be supplied as well.
Example Usage
data "vsphere_datacenter" "datacenter" {
name = "dc1"
}
data "vsphere_virtual_machine" "template" {
name = "test-vm-template"
datacenter_id = "${data.vsphere_datacenter.datacenter.id}"
}
Argument Reference
The following arguments are supported:
-
name- (Required) The name of the virtual machine. This can be a name or path. -
datacenter_id- (Optional) The managed object reference ID of the datacenter the virtual machine is located in. This can be omitted if the search path used innameis an absolute path. For default datacenters, use theidattribute from an emptyvsphere_datacenterdata source. -
scsi_controller_scan_count- (Optional) The number of SCSI controllers to scan for disk attributes and controller types on. Default:1.
NOTE: For best results, ensure that all the disks on any templates you use with this data source reside on the primary controller, and leave this value at the default. See the
vsphere_virtual_machineresource documentation for the significance of this setting, specifically the additional requirements and notes for cloning section.
Attribute Reference
The following attributes are exported:
-
id- The UUID of the virtual machine or template. -
guest_id- The guest ID of the virtual machine or template. -
alternate_guest_name- The alternate guest name of the virtual machine when guest_id is a non-specific operating system, likeotherGuest. -
scsi_type- The common type of all SCSI controllers on this virtual machine. Will be one oflsilogic(LSI Logic Parallel),lsilogic-sas(LSI Logic SAS),pvscsi(VMware Paravirtual),buslogic(BusLogic), ormixedwhen there are multiple controller types. Only the first number of controllers defined byscsi_controller_scan_countare scanned. -
disks- Information about each of the disks on this virtual machine or template. These are sorted by bus and unit number so that they can be applied to avsphere_virtual_machineresource in the order the resource expects while cloning. This is useful for discovering certain disk settings while performing a linked clone, as all settings that are output by this data source must be the same on the destination virtual machine as the source. Only the first number of controllers defined byscsi_controller_scan_countare scanned for disks. The sub-attributes are:-
size- The size of the disk, in GIB. -
eagerly_scrub- Set totrueif the disk has been eager zeroed. -
thin_provisioned- Set totrueif the disk has been thin provisioned.
-
-
network_interface_types- The network interface types for each network interface found on the virtual machine, in device bus order. Will be one ofe1000,e1000e,pcnet32,sriov,vmxnet2, orvmxnet3. -
firmware- The firmware type for this virtual machine. Can bebiosorefi.
NOTE: Keep in mind when using the results of
scsi_typeandnetwork_interface_types, that thevsphere_virtual_machineresource only supports a subset of the types returned from this data source. See the resource docs for more details.
© 2018 HashiCorpLicensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/vsphere/d/virtual_machine.html