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