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