» 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 inname
is an absolute path. For default datacenters, use theid
attribute from an emptyvsphere_datacenter
data 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_machine
resource
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), ormixed
when there are multiple controller types. Only the first number of controllers defined byscsi_controller_scan_count
are scanned. -
scsi_bus_sharing
- Mode for sharing the SCSI bus. The modes are physicalSharing, virtualSharing, and noSharing. Only the first number of controllers defined byscsi_controller_scan_count
are 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_machine
resource 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_count
are scanned for disks. The sub-attributes are:-
size
- The size of the disk, in GIB. -
eagerly_scrub
- Set totrue
if the disk has been eager zeroed. -
thin_provisioned
- Set totrue
if 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 bebios
orefi
.
NOTE: Keep in mind when using the results of scsi_type
and
network_interface_types
, that the vsphere_virtual_machine
resource only
supports a subset of the types returned from this data source. See the
resource docs for more details.