You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a new option `shared-pci-device-id` to the `virtual machine` resource. This enables users to 1 or more vGPU to the VM as an update to the resource or during the clone operation.
Copy file name to clipboardExpand all lines: docs/resources/virtual_machine.md
+39-25Lines changed: 39 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -628,6 +628,8 @@ The following options are general virtual machine and provider workflow options:
628
628
629
629
*`clone` - (Optional) When specified, the virtual machine will be created as a clone of a specified template. Optional customization options can be submitted for the resource. See [creating a virtual machine from a template](#creating-a-virtual-machine-from-a-template) for more information.
630
630
631
+
~> **NOTE:** Cloning requires vCenter Server and is not supported on direct ESXi host connections.
632
+
631
633
*`extra_config_reboot_required` - (Optional) Allow the virtual machine to be rebooted when a change to `extra_config` occurs. Default: `true`.
632
634
633
635
*`custom_attributes` - (Optional) Map of custom attribute ids to attribute value strings to set for virtual machine. Please refer to the [`vsphere_custom_attributes`][docs-setting-custom-attributes] resource for more information on setting custom attributes.
@@ -656,7 +658,7 @@ The following options are general virtual machine and provider workflow options:
656
658
657
659
*`firmware` - (Optional) The firmware for the virtual machine. One of `bios` or `efi`.
658
660
659
-
*`folder` - (Optional) The path to the virtual machine folder in which to place the virtual machine, relative to the datacenter path (`/<datacenter-name>/vm`). For example, `/dc-01/vm/foo`
661
+
*`folder` - (Optional) The path to the virtual machine folder in which to place the virtual machine, relative to the datacenter path (`/<datacenter-name>/vm`). For example, `/dc-01/vm/foo`
660
662
661
663
*`guest_id` - (Optional) The guest ID for the operating system type. Default: `otherGuest64`.
662
664
@@ -684,13 +686,13 @@ The following options are general virtual machine and provider workflow options:
684
686
685
687
*`pci_device_id` - (Optional) List of host PCI device IDs in which to create PCI passthroughs.
686
688
687
-
~> **NOTE:** Cloning requires vCenter Server and is not supported on direct ESXi host connections.
689
+
*`shared_pci_device_id` - (Optional) A shared PCI device ID to create PCI passthrough.
688
690
689
691
*`ovf_deploy` - (Optional) When specified, the virtual machine will be deployed from the provided OVF/OVA template. See [creating a virtual machine from an OVF/OVA template](#creating-a-virtual-machine-from-an-ovf-ova-template) for more information.
690
692
691
693
*`replace_trigger` - (Optional) Triggers replacement of resource whenever it changes.
692
694
693
-
For example, `replace_trigger = sha256(format("%s-%s",data.template_file.cloud_init_metadata.rendered,data.template_file.cloud_init_userdata.rendered))` will fingerprint the changes in cloud-init metadata and userdata templates. This will enable a replacement of the resource whenever the dependant template renders a new configuration. (Forces a replacement.)
695
+
For example, `replace_trigger = sha256(format("%s-%s",data.template_file.cloud_init_metadata.rendered,data.template_file.cloud_init_userdata.rendered))` will fingerprint the changes in cloud-init metadata and user-data templates. This will enable a replacement of the resource whenever the dependant template renders a new configuration. (Forces a replacement.)
694
696
695
697
*`resource_pool_id` - (Required) The [managed object reference ID][docs-about-morefs] of the resource pool in which to place the virtual machine. See the [Virtual Machine Migration](#virtual-machine-migration) section for more information on modifying this value.
696
698
@@ -706,6 +708,17 @@ For example, `replace_trigger = sha256(format("%s-%s",data.template_file.cloud_i
706
708
707
709
*`storage_policy_id` - (Optional) The ID of the storage policy to assign to the home directory of a virtual machine.
708
710
711
+
*`shared_pci_device_id` - (Optional) List of shared PCI device(s) to create
712
+
shared PCI passthrough.
713
+
714
+
For example, attaching a vGPU to the virtual machine: `shared_pci_device_id = ["grid_a100d-40c"]`
715
+
716
+
~> **NOTE:** The use of vGPU requires that the VM has memory reservation set equal
717
+
to the amount of provisioned memory. This can be accomplished by leveraging
718
+
the [`memory_reservation`](#memory_reservation) option.
719
+
720
+
*`storage_policy_id` - (Optional) The ID of the storage policy to assign to the home directory of a virtual machine.
721
+
709
722
*`tags` - (Optional) The IDs of any tags to attach to this resource. Please refer to the [`vsphere_tag`][docs-applying-tags] resource for more information on applying tags to virtual machine resources.
Virtual disks are managed by adding one or more instance of the `disk` block.
852
865
853
-
At a minimum, both the `label` and `size` attributes must be provided. The `unit_number` is required for any disk other than the first, and there must be at least one resource with the implicit number of `0`.
866
+
At a minimum, both the `label` and `size` attributes must be provided. The `unit_number` is required for any disk other than the first, and there must be at least one resource with the implicit number of `0`.
854
867
855
868
The following example demonstrates an abridged multi-disk configuration:
856
869
@@ -903,7 +916,7 @@ an error if you try to label a disk with this prefix.
*`eagerly_scrub` - (Optional) If set to `true`, the disk space is zeroed out when the virtual machine is created. This will delay the creation of the virtual disk. Cannot be set to `true` when `thin_provisioned` is `true`. See the section on [picking a disk type](#picking-a-disk-type) for more information. Default: `false`.
919
+
*`eagerly_scrub` - (Optional) If set to `true`, the disk space is zeroed out when the virtual machine is created. This will delay the creation of the virtual disk. Cannot be set to `true` when `thin_provisioned` is `true`. See the section on [picking a disk type](#picking-a-disk-type) for more information. Default: `false`.
907
920
908
921
*`thin_provisioned` - (Optional) If `true`, the disk is thin provisioned, with space for the file being allocated on an as-needed basis. Cannot be set to `true` when `eagerly_scrub` is `true`. See the section on [selecting a disk type](#selecting-a-disk-type) for more information. Default: `true`.
909
922
@@ -913,7 +926,7 @@ an error if you try to label a disk with this prefix.
913
926
914
927
*`io_limit` - (Optional) The upper limit of IOPS that this disk can use. The default is no limit.
915
928
916
-
*`io_reservation` - (Optional) The I/O reservation (guarantee) for the virtual disk has, in IOPS. The default is no reservation.
929
+
*`io_reservation` - (Optional) The I/O reservation (guarantee) for the virtual disk has, in IOPS. The default is no reservation.
917
930
918
931
*`io_share_level` - (Optional) The share allocation level for the virtual disk. One of `low`, `normal`, `high`, or `custom`. Default: `normal`.
919
932
@@ -1041,6 +1054,7 @@ there are a few requirements
1041
1054
* The `memory_reservation` must be fully set (that is, equal to the `memory`) for the VM.
1042
1055
1043
1056
* The `network_interface` sub-resource takes a `physical_function` argument:
1057
+
1044
1058
* This **must** be set if your adapter type is `sriov`.
1045
1059
* This **must not** be set if your adapter type is not `sriov`.
1046
1060
* This can be found by navigating to the relevant host in the vSphere Client,
@@ -1221,7 +1235,7 @@ The options are:
1221
1235
1222
1236
*`ipv6_address` - (Optional) The IPv6 address assigned to the network adapter. If blank or not included, auto-configuration is used.
1223
1237
1224
-
*`ipv6_netmask` - (Optional) The IPv6 subnet mask, in bits (_e.g._`32`).
1238
+
*`ipv6_netmask` - (Optional) The IPv6 subnet mask, in bits (_e.g._`32`).
1225
1239
1226
1240
~> **NOTE:** The minimum setting for IPv4 in a customization specification is DHCP. If you are setting up an IPv6-exclusive network without DHCP, you may need to set [`wait_for_guest_net_timeout`](#wait_for_guest_net_timeout) to a high enough value to cover the DHCP timeout of your virtual machine, or disable by supplying a zero or negative value. Disabling `wait_for_guest_net_timeout` may result in IP addresses not being reported to any provisioners you may have configured on the resource.
1227
1241
@@ -1313,7 +1327,7 @@ The options are:
1313
1327
1314
1328
*`admin_password` - (Optional) The administrator password for the virtual machine.
1315
1329
1316
-
~> **NOTE:**`admin_password` is a sensitive field and will not be output on-screen, but is stored in state and sent to the virtual machine in plain text.
1330
+
~> \*_NOTE:_*`admin_password` is a sensitive field and will not be output on-screen, but is stored in state and sent to the virtual machine in plain text.
1317
1331
1318
1332
*`workgroup` - (Optional) The workgroup name for the virtual machine. One of this or `join_domain` must be included.
*`domain_admin_password` - (Optional) The password user account with administrative privileges used to join the virtual machine to the domain. Required if setting `join_domain`.
1348
1362
1349
-
~> **NOTE:**`domain_admin_password` is a sensitive field and will not be output on-screen, but is stored in state and sent to the virtual machine in plain text
1363
+
~> \*_NOTE:_*`domain_admin_password` is a sensitive field and will not be output on-screen, but is stored in state and sent to the virtual machine in plain text
1350
1364
1351
1365
*`full_name` - (Optional) The full name of the organization owner of the virtual machine. This populates the "user" field in the general Windows system information. Default: `Administrator`.
When cloning from a template, there are additional requirements in both the resource configuration and source template:
1509
1523
1510
-
* The virtual machine must not be powered on at the time of cloning.
1511
-
* All disks on the virtual machine must be SCSI disks.
1512
-
* You must specify at least the same number of `disk` devices as there are disks that exist in the template. These devices are ordered and lined up by the `unit_number` attribute. Additional disks can be added past this.
1513
-
* The `size` of a virtual disk must be at least the same size as its counterpart disk in the source template.
1514
-
* When using `linked_clone`, the `size`, `thin_provisioned`, and `eagerly_scrub` settings for each disk must be an exact match to the individual disk's counterpart in the source template.
1515
-
* The storage controller count settings should be configured as necessary to cover all of the disks on the template. For best results, only configure this setting for the number of controllers you will need to cover your disk quantity and bandwidth needs, and configure your template accordingly. For most workloads, this setting should be kept at the default of `1` SCSI controller, and all disks in the template should reside on the single, primary controller.
1516
-
* Some operating systems do not respond well to a change in disk controller type. Ensure that `scsi_type` is set to an exact match of the template's controller set. For maximum compatibility, make sure the SCSI controllers on the source template are all the same type.
1524
+
- The virtual machine must not be powered on at the time of cloning.
1525
+
- All disks on the virtual machine must be SCSI disks.
1526
+
- You must specify at least the same number of `disk` devices as there are disks that exist in the template. These devices are ordered and lined up by the `unit_number` attribute. Additional disks can be added past this.
1527
+
- The `size` of a virtual disk must be at least the same size as its counterpart disk in the source template.
1528
+
- When using `linked_clone`, the `size`, `thin_provisioned`, and `eagerly_scrub` settings for each disk must be an exact match to the individual disk's counterpart in the source template.
1529
+
- The storage controller count settings should be configured as necessary to cover all of the disks on the template. For best results, only configure this setting for the number of controllers you will need to cover your disk quantity and bandwidth needs, and configure your template accordingly. For most workloads, this setting should be kept at the default of `1` SCSI controller, and all disks in the template should reside on the single, primary controller.
1530
+
- Some operating systems do not respond well to a change in disk controller type. Ensure that `scsi_type` is set to an exact match of the template's controller set. For maximum compatibility, make sure the SCSI controllers on the source template are all the same type.
1517
1531
1518
1532
You can use the [`vsphere_virtual_machine`][tf-vsphere-virtual-machine-ds] data source, which provides disk attributes, network interface types, SCSI bus types, and the guest ID of the source template, to return this information. See the section on [cloning and customization](#cloning-and-customization) for more information.
1519
1533
@@ -1549,9 +1563,9 @@ The same rules apply for migration as they do for virtual machine creation - any
1549
1563
1550
1564
Storage migration can be done on two levels:
1551
1565
1552
-
* Global datastore migration can be handled by changing the global `datastore_id` attribute. This triggers a storage migration for all disks that do not have an explicit `datastore_id` specified.
1553
-
* When using Storage DRS through the `datastore_cluster_id` attribute, the entire virtual machine can be migrated from one datastore cluster to another by changing the value of this setting. In addition, when `datastore_cluster_id` is in use, any disks that drift to datastores outside of the datastore cluster via such actions as manual modification will be migrated back to the datastore cluster on the next apply.
1554
-
* An individual `disk` device can be migrated by manually specifying the `datastore_id` in its configuration block. This also pins it to the specific datastore that is specified - if at a later time the virtual machine and any unpinned disks migrate to another host, the disk will stay on the specified datastore.
1566
+
- Global datastore migration can be handled by changing the global `datastore_id` attribute. This triggers a storage migration for all disks that do not have an explicit `datastore_id` specified.
1567
+
- When using Storage DRS through the `datastore_cluster_id` attribute, the entire virtual machine can be migrated from one datastore cluster to another by changing the value of this setting. In addition, when `datastore_cluster_id` is in use, any disks that drift to datastores outside of the datastore cluster via such actions as manual modification will be migrated back to the datastore cluster on the next apply.
1568
+
- An individual `disk` device can be migrated by manually specifying the `datastore_id` in its configuration block. This also pins it to the specific datastore that is specified - if at a later time the virtual machine and any unpinned disks migrate to another host, the disk will stay on the specified datastore.
1555
1569
1556
1570
An example of datastore pinning is below. As long as the datastore in the `pinned_datastore` data source does not change, any change to the standard `vm_datastore` data source will not affect the data disk - the disk will stay where it is.
1557
1571
@@ -1629,7 +1643,7 @@ The following attributes are exported on the base level of this resource:
1629
1643
1630
1644
*`reboot_required` - Value internal to Terraform used to determine if a configuration set change requires a reboot. This value is most useful during an update process and gets reset on refresh.
1631
1645
1632
-
*`vmware_tools_status` - The state of VMware Tools in the guest. This will determine the proper course of action for some device operations.
1646
+
*`vmware_tools_status` - The state of VMware Tools in the guest. This will determine the proper course of action for some device operations.
1633
1647
1634
1648
*`vmx_path` - The path of the virtual machine configuration file on the datastore in which the virtual machine is placed.
1635
1649
@@ -1681,17 +1695,17 @@ The following requirements apply to import:
1681
1695
1682
1696
~> **NOTE:** Any custom `label` set at deployment of machine through Terraform, on import will not have the custom `label` and will default to `Hard Disk _x_`.
1683
1697
1684
-
* Disks are always imported with [`keep_on_remove`](#keep_on_remove) enabled until the first `terraform apply` run which will remove the setting for known disks. This process safeguards against naming or accounting mistakes in the disk configuration.
1698
+
- Disks are always imported with [`keep_on_remove`](#keep_on_remove) enabled until the first `terraform apply` run which will remove the setting for known disks. This process safeguards against naming or accounting mistakes in the disk configuration.
1685
1699
1686
-
* The storage controller count for the resource is set to the number of contiguous storage controllers found, starting with the controller at SCSI bus number `0`. If no storage controllers are discovered, the virtual machine is not eligible for import. For maximum compatibility, ensure that the virtual machine has the exact number of storage controllers needed and set the storage controller count accordingly.
1700
+
- The storage controller count for the resource is set to the number of contiguous storage controllers found, starting with the controller at SCSI bus number `0`. If no storage controllers are discovered, the virtual machine is not eligible for import. For maximum compatibility, ensure that the virtual machine has the exact number of storage controllers needed and set the storage controller count accordingly.
1687
1701
1688
1702
After importing, you should run `terraform plan`. Unless you have changed anything else in the configuration that would cause other attributes to change. The only difference should be configuration-only changes, which are typically comprised of:
1689
1703
1690
-
* The [`imported`](#imported) flag will transition from `true` to `false`.
1704
+
- The [`imported`](#imported) flag will transition from `true` to `false`.
1691
1705
1692
-
* The [`keep_on_remove`](#keep_on_remove) of known disks will transition from `true` to `false`.
1706
+
- The [`keep_on_remove`](#keep_on_remove) of known disks will transition from `true` to `false`.
1693
1707
1694
-
* Configuration supplied in the [`clone`](#clone) block, if present, will be persisted to state. This initial persistence operation does not perform any cloning or customization actions, nor does it force a new resource. After the first apply operation, further changes to `clone` will force the creation of a new resource.
1708
+
- Configuration supplied in the [`clone`](#clone) block, if present, will be persisted to state. This initial persistence operation does not perform any cloning or customization actions, nor does it force a new resource. After the first apply operation, further changes to `clone` will force the creation of a new resource.
1695
1709
1696
1710
~> **NOTE:** Do not make any configuration changes to `clone` after importing or upgrading from a legacy version of the provider before doing an initial `terraform apply` as these changes will not correctly force a new resource and your changes will have persisted to state, preventing further plans from correctly triggering a diff.
0 commit comments