github.com/sarguru/terraform@v0.6.17-0.20160525232901-8fcdfd7e3dc9/website/source/docs/providers/vsphere/index.html.markdown (about) 1 --- 2 layout: "vsphere" 3 page_title: "Provider: VMware vSphere" 4 sidebar_current: "docs-vsphere-index" 5 description: |- 6 The VMware vSphere provider is used to interact with the resources supported by 7 VMware vSphere. The provider needs to be configured with the proper credentials 8 before it can be used. 9 --- 10 11 # VMware vSphere Provider 12 13 The VMware vSphere provider is used to interact with the resources supported by 14 VMware vSphere. 15 The provider needs to be configured with the proper credentials before it can be used. 16 17 Use the navigation to the left to read about the available resources. 18 19 ~> **NOTE:** The VMware vSphere Provider currently represents _initial support_ 20 and therefore may undergo significant changes as the community improves it. This 21 provider at this time only supports IPv4 addresses on virtual machines. 22 23 ## Example Usage 24 25 ``` 26 # Configure the VMware vSphere Provider 27 provider "vsphere" { 28 user = "${var.vsphere_user}" 29 password = "${var.vsphere_password}" 30 vsphere_server = "${var.vsphere_server}" 31 } 32 33 # Create a folder 34 resource "vsphere_folder" "frontend" { 35 path = "frontend" 36 } 37 38 # Create a file 39 resource "vsphere_file" "ubuntu_disk" { 40 datastore = "local" 41 source_file = "/home/ubuntu/my_disks/custom_ubuntu.vmdk" 42 destination_file = "/my_path/disks/custom_ubuntu.vmdk" 43 } 44 45 # Create a disk image 46 resource "vsphere_virtual_disk" "extraStorage" { 47 size = 2 48 vmdk_path = "myDisk.vmdk" 49 datacenter = "Datacenter" 50 datastore = "local" 51 } 52 53 # Create a virtual machine within the folder 54 resource "vsphere_virtual_machine" "web" { 55 name = "terraform-web" 56 folder = "${vsphere_folder.frontend.path}" 57 vcpu = 2 58 memory = 4096 59 60 network_interface { 61 label = "VM Network" 62 } 63 64 disk { 65 template = "centos-7" 66 } 67 } 68 ``` 69 70 ## Argument Reference 71 72 The following arguments are used to configure the VMware vSphere Provider: 73 74 * `user` - (Required) This is the username for vSphere API operations. Can also 75 be specified with the `VSPHERE_USER` environment variable. 76 * `password` - (Required) This is the password for vSphere API operations. Can 77 also be specified with the `VSPHERE_PASSWORD` environment variable. 78 * `vsphere_server` - (Required) This is the vCenter server name for vSphere API 79 operations. Can also be specified with the `VSPHERE_SERVER` environment 80 variable. 81 * `allow_unverified_ssl` - (Optional) Boolean that can be set to true to 82 disable SSL certificate verification. This should be used with care as it 83 could allow an attacker to intercept your auth token. If omitted, default 84 value is `false`. Can also be specified with the `VSPHERE_ALLOW_UNVERIFIED_SSL` 85 environment variable. 86 87 ## Required Privileges 88 89 In order to use Terraform provider as non priviledged user, a Role within 90 vCenter must be assigned the following privileges: 91 92 * Datastore 93 - Allocate space 94 - Browse datastore 95 - Low level file operations 96 - Remove file 97 - Update virtual machine files 98 - Update virtual machine metadata 99 100 * Folder (all) 101 - Create folder 102 - Delete folder 103 - Move folder 104 - Rename folder 105 106 * Network 107 - Assign network 108 109 * Resource 110 - Apply recommendation 111 - Assign virtual machine to resource pool 112 113 * Virtual Machine 114 - Configuration (all) - for now 115 - Guest Operations (all) - for now 116 - Interaction (all) 117 - Inventory (all) 118 - Provisioning (all) 119 120 These settings were tested with [vSphere 121 6.0](https://pubs.vmware.com/vsphere-60/index.jsp?topic=%2Fcom.vmware.vsphere.security.doc%2FGUID-18071E9A-EED1-4968-8D51-E0B4F526FDA3.html) 122 and [vSphere 123 5.5](https://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.vsphere.security.doc%2FGUID-18071E9A-EED1-4968-8D51-E0B4F526FDA3.html). 124 For additional information on roles and permissions, please refer to official 125 VMware documentation. 126 127 ## Virtual Machine Customization 128 129 Guest Operating Systems can be configured using 130 [customizations](https://pubs.vmware.com/vsphere-50/index.jsp#com.vmware.vsphere.vm_admin.doc_50/GUID-80F3F5B5-F795-45F1-B0FA-3709978113D5.html), 131 in order to set things properties such as domain and hostname. This mechanism 132 is not compatible with all operating systems, however. A list of compatible 133 operating systems can be found 134 [here](http://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf) 135 136 If customization is attempted on an operating system which is not supported, Terraform will 137 create the virtual machine, but fail with the following error message: 138 139 ``` 140 Customization of the guest operating system 'debian6_64Guest' is not 141 supported in this configuration. Microsoft Vista (TM) and Linux guests with 142 Logical Volume Manager are supported only for recent ESX host and VMware Tools 143 versions. Refer to vCenter documentation for supported configurations. ``` 144 ``` 145 146 In order to skip the customization step for unsupported operating systems, use 147 the `skip_customization` argument on the virtual machine resource. 148 149 ## Acceptance Tests 150 151 The VMware vSphere provider's acceptance tests require the above provider 152 configuration fields to be set using the documented environment variables. 153 154 In addition, the following environment variables are used in tests, and must be 155 set to valid values for your VMware vSphere environment: 156 157 * VSPHERE\_IPV4\_GATEWAY 158 * VSPHERE\_IPV4\_ADDRESS 159 * VSPHERE\_IPV6\_GATEWAY 160 * VSPHERE\_IPV6\_ADDRESS 161 * VSPHERE\_NETWORK\_LABEL 162 * VSPHERE\_NETWORK\_LABEL\_DHCP 163 * VSPHERE\_TEMPLATE 164 165 The following environment variables depend on your vSphere environment: 166 167 * VSPHERE\_DATACENTER 168 * VSPHERE\_CLUSTER 169 * VSPHERE\_RESOURCE\_POOL 170 * VSPHERE\_DATASTORE 171 172 The following additional environment variables are needed for running the 173 "Mount ISO as CDROM media" acceptance tests. 174 175 * VSPHERE\_CDROM\_DATASTORE 176 * VSPHERE\_CDROM\_PATH 177 178 179 These are used to set and verify attributes on the `vsphere_virtual_machine` 180 resource in tests. 181 182 Once all these variables are in place, the tests can be run like this: 183 184 ``` 185 make testacc TEST=./builtin/providers/vsphere 186 ``` 187 188