github.com/adrian-bl/terraform@v0.7.0-rc2.0.20160705220747-de0a34fc3517/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown (about) 1 --- 2 layout: "vsphere" 3 page_title: "VMware vSphere: vsphere_virtual_machine" 4 sidebar_current: "docs-vsphere-resource-virtual-machine" 5 description: |- 6 Provides a VMware vSphere virtual machine resource. This can be used to create, modify, and delete virtual machines. 7 --- 8 9 # vsphere\_virtual\_machine 10 11 Provides a VMware vSphere virtual machine resource. This can be used to create, 12 modify, and delete virtual machines. 13 14 ## Example Usage 15 16 ``` 17 resource "vsphere_virtual_machine" "web" { 18 name = "terraform_web" 19 vcpu = 2 20 memory = 4096 21 22 network_interface { 23 label = "VM Network" 24 } 25 26 disk { 27 template = "centos-7" 28 } 29 } 30 ``` 31 32 ## Example Usage VMware Cluster 33 34 ``` 35 resource "vsphere_virtual_machine" "lb" { 36 name = "lb01" 37 folder = "Loadbalancers" 38 vcpu = 2 39 memory = 4096 40 domain = "MYDOMAIN" 41 datacenter = "EAST" 42 cluster = "Production Cluster" 43 resource_pool = "Production Cluster/Resources/Production Servers" 44 45 gateway = "10.20.30.254" 46 47 network_interface { 48 label = "10_20_30_VMNet" 49 ipv4_address = "10.20.30.40" 50 ipv4_prefix_length = "24" 51 } 52 53 disk { 54 datastore = "EAST/VMFS01-EAST" 55 template = "Templates/Centos7" 56 } 57 } 58 ``` 59 60 ## Argument Reference 61 62 The following arguments are supported: 63 64 * `name` - (Required) The virtual machine name 65 * `vcpu` - (Required) The number of virtual CPUs to allocate to the virtual machine 66 * `memory` - (Required) The amount of RAM (in MB) to allocate to the virtual machine 67 * `memory_reservation` - (Optional) The amount of RAM (in MB) to reserve physical memory resource; defaults to 0 (means not to reserve) 68 * `datacenter` - (Optional) The name of a Datacenter in which to launch the virtual machine 69 * `cluster` - (Optional) Name of a Cluster in which to launch the virtual machine 70 * `resource_pool` (Optional) The name of a Resource Pool in which to launch the virtual machine. Requires full path (see cluster example). 71 * `gateway` - __Deprecated, please use `network_interface.ipv4_gateway` instead__. 72 * `domain` - (Optional) A FQDN for the virtual machine; defaults to "vsphere.local" 73 * `time_zone` - (Optional) The [Linux](https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/timezone.html) or [Windows](https://msdn.microsoft.com/en-us/library/ms912391.aspx) time zone to set on the virtual machine. Defaults to "Etc/UTC" 74 * `dns_suffixes` - (Optional) List of name resolution suffixes for the virtual network adapter 75 * `dns_servers` - (Optional) List of DNS servers for the virtual network adapter; defaults to 8.8.8.8, 8.8.4.4 76 * `network_interface` - (Required) Configures virtual network interfaces; see [Network Interfaces](#network-interfaces) below for details. 77 * `disk` - (Required) Configures virtual disks; see [Disks](#disks) below for details 78 * `cdrom` - (Optional) Configures a CDROM device and mounts an image as its media; see [CDROM](#cdrom) below for more details. 79 * `windows_opt_config` - (Optional) Extra options for clones of Windows machines. 80 * `linked_clone` - (Optional) Specifies if the new machine is a [linked clone](https://www.vmware.com/support/ws5/doc/ws_clone_overview.html#wp1036396) of another machine or not. 81 * `enable_disk_uuid` - (Optional) This option causes the vm to mount disks by uuid on the guest OS. 82 * `custom_configuration_parameters` - (Optional) Map of values that is set as virtual machine custom configurations. 83 * `skip_customization` - (Optional) skip virtual machine customization (useful if OS is not in the guest OS support matrix of VMware like "other3xLinux64Guest"). 84 85 The `network_interface` block supports: 86 87 * `label` - (Required) Label to assign to this network interface 88 * `ipv4_address` - (Optional) Static IPv4 to assign to this network interface. Interface will use DHCP if this is left blank. 89 * `ipv4_prefix_length` - (Optional) prefix length to use when statically assigning an IPv4 address. 90 * `ipv4_gateway` - (Optional) IPv4 gateway IP address to use. 91 * `ipv6_address` - (Optional) Static IPv6 to assign to this network interface. Interface will use DHCPv6 if this is left blank. 92 * `ipv6_prefix_length` - (Optional) prefix length to use when statically assigning an IPv6. 93 * `ipv6_gateway` - (Optional) IPv6 gateway IP address to use. 94 * `mac_address` - (Optional) Manual MAC address to assign to this network interface. Will be generated by VMware if not set. ([VMware KB: Setting a static MAC address for a virtual NIC (219)](https://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=219)) 95 96 The following arguments are maintained for backwards compatibility and may be 97 removed in a future version: 98 99 * `ip_address` - __Deprecated, please use `ipv4_address` instead__. 100 * `subnet_mask` - __Deprecated, please use `ipv4_prefix_length` instead__. 101 102 The `windows_opt_config` block supports: 103 104 * `product_key` - (Optional) Serial number for new installation of Windows. This serial number is ignored if the original guest operating system was installed using a volume-licensed CD. 105 * `admin_password` - (Optional) The password for the new `administrator` account. Omit for passwordless admin (using `""` does not work). 106 * `domain` - (Optional) Domain that the new machine will be placed into. If `domain`, `domain_user`, and `domain_user_password` are not all set, all three will be ignored. 107 * `domain_user` - (Optional) User that is a member of the specified domain. 108 * `domain_user_password` - (Optional) Password for domain user, in plain text. 109 110 <a id="disks"></a> 111 ## Disks 112 113 The `disk` block supports: 114 115 * `template` - (Required if size and bootable_vmdk_path not provided) Template for this disk. 116 * `datastore` - (Optional) Datastore for this disk 117 * `size` - (Required if template and bootable_vmdks_path not provided) Size of this disk (in GB). 118 * `name` - (Required if size is provided when creating a new disk) This "name" is used for the disk file name in vSphere, when the new disk is created. 119 * `iops` - (Optional) Number of virtual iops to allocate for this disk. 120 * `type` - (Optional) 'eager_zeroed' (the default), or 'thin' are supported options. 121 * `vmdk` - (Required if template and size not provided) Path to a vmdk in a vSphere datastore. 122 * `bootable` - (Optional) Set to 'true' if a vmdk was given and it should attempt to boot after creation. 123 * `controller_type` = (Optional) Controller type to attach the disk to. 'scsi' (the default), or 'ide' are supported options. 124 125 <a id="cdrom"></a> 126 ## CDROM 127 128 The `cdrom` block supports: 129 130 * `datastore` - (Required) The name of the datastore where the disk image is stored. 131 * `path` - (Required) The absolute path to the image within the datastore. 132 133 ## Attributes Reference 134 135 The following attributes are exported: 136 137 * `id` - The instance ID. 138 * `uuid` - The instance UUID. 139 * `name` - See Argument Reference above. 140 * `vcpu` - See Argument Reference above. 141 * `memory` - See Argument Reference above. 142 * `datacenter` - See Argument Reference above. 143 * `network_interface/label` - See Argument Reference above. 144 * `network_interface/ipv4_address` - See Argument Reference above. 145 * `network_interface/ipv4_prefix_length` - See Argument Reference above. 146 * `network_interface/ipv6_address` - Assigned static IPv6 address. 147 * `network_interface/ipv6_prefix_length` - Prefix length of assigned static IPv6 address.