github.com/adrian-bl/terraform@v0.7.0-rc2.0.20160705220747-de0a34fc3517/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  * `client_debug` - (Optional) Boolean to set the govomomi api to log soap calls
    87     to disk.  The log files are logged to `${HOME}/.govc`, the same path used by
    88    `govc`.  Can also be specified with the `VSPHERE_CLIENT_DEBUG` environment 
    89     variable.
    90  * `client_debug_path` - (Optional) Override the default log path. Can also 
    91     be specified with the `VSPHERE_CLIENT_DEBUG_PATH` environment variable.
    92  * `client_debug_path_run` - (Optional) Client debug file path for a single run. Can also 
    93     be specified with the `VSPHERE_CLIENT_DEBUG_PATH_RUN` environment variable.
    94  
    95  ## Required Privileges
    96  
    97  In order to use Terraform provider as non priviledged user, a Role within
    98  vCenter must be assigned the following privileges:
    99  
   100  * Datastore
   101     - Allocate space
   102     - Browse datastore
   103     - Low level file operations
   104     - Remove file
   105     - Update virtual machine files
   106     - Update virtual machine metadata
   107  
   108  * Folder (all)
   109     - Create folder
   110     - Delete folder
   111     - Move folder
   112     - Rename folder
   113  
   114  * Network
   115     - Assign network
   116  
   117  * Resource
   118     - Apply recommendation
   119     - Assign virtual machine to resource pool
   120  
   121  * Virtual Machine
   122     - Configuration (all) - for now
   123     - Guest Operations (all) - for now
   124     - Interaction (all)
   125     - Inventory (all)
   126     - Provisioning (all)
   127  
   128  These settings were tested with [vSphere
   129  6.0](https://pubs.vmware.com/vsphere-60/index.jsp?topic=%2Fcom.vmware.vsphere.security.doc%2FGUID-18071E9A-EED1-4968-8D51-E0B4F526FDA3.html)
   130  and [vSphere
   131  5.5](https://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.vsphere.security.doc%2FGUID-18071E9A-EED1-4968-8D51-E0B4F526FDA3.html).
   132  For additional information on roles and permissions, please refer to official
   133  VMware documentation.
   134  
   135  ## Virtual Machine Customization
   136  
   137  Guest Operating Systems can be configured using
   138  [customizations](https://pubs.vmware.com/vsphere-50/index.jsp#com.vmware.vsphere.vm_admin.doc_50/GUID-80F3F5B5-F795-45F1-B0FA-3709978113D5.html),
   139  in order to set things properties such as domain and hostname. This mechanism
   140  is not compatible with all operating systems, however. A list of compatible
   141  operating systems can be found
   142  [here](http://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf)
   143  
   144  If customization is attempted on an operating system which is not supported, Terraform will
   145  create the virtual machine, but fail with the following error message:
   146  
   147  ```
   148  Customization of the guest operating system 'debian6_64Guest' is not
   149  supported in this configuration. Microsoft Vista (TM) and Linux guests with
   150  Logical Volume Manager are supported only for recent ESX host and VMware Tools
   151  versions. Refer to vCenter documentation for supported configurations.  ```
   152  ```
   153  
   154  In order to skip the customization step for unsupported operating systems, use
   155  the `skip_customization` argument on the virtual machine resource.
   156  
   157  ## Acceptance Tests
   158  
   159  The VMware vSphere provider's acceptance tests require the above provider
   160  configuration fields to be set using the documented environment variables.
   161  
   162  In addition, the following environment variables are used in tests, and must be
   163  set to valid values for your VMware vSphere environment:
   164  
   165   * VSPHERE\_IPV4\_GATEWAY
   166   * VSPHERE\_IPV4\_ADDRESS
   167   * VSPHERE\_IPV6\_GATEWAY
   168   * VSPHERE\_IPV6\_ADDRESS
   169   * VSPHERE\_NETWORK\_LABEL
   170   * VSPHERE\_NETWORK\_LABEL\_DHCP
   171   * VSPHERE\_TEMPLATE
   172   * VSPHERE\_MAC\_ADDRESS
   173  
   174  The following environment variables depend on your vSphere environment:
   175  
   176   * VSPHERE\_DATACENTER
   177   * VSPHERE\_CLUSTER
   178   * VSPHERE\_RESOURCE\_POOL
   179   * VSPHERE\_DATASTORE
   180  
   181  The following additional environment variables are needed for running the
   182  "Mount ISO as CDROM media" acceptance tests.
   183  
   184   * VSPHERE\_CDROM\_DATASTORE
   185   * VSPHERE\_CDROM\_PATH
   186  
   187  
   188  These are used to set and verify attributes on the `vsphere_virtual_machine`
   189  resource in tests.
   190  
   191  Once all these variables are in place, the tests can be run like this:
   192  
   193  ```
   194  make testacc TEST=./builtin/providers/vsphere
   195  ```
   196  
   197