github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/website/source/docs/builders/vmware-iso.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "VMware Builder from ISO"
     4  description: |-
     5    This VMware Packer builder is able to create VMware virtual machines from an ISO file as a source. It currently supports building virtual machines on hosts running VMware Fusion for OS X, VMware Workstation for Linux and Windows, and VMware Player on Linux. It can also build machines directly on VMware vSphere Hypervisor using SSH as opposed to the vSphere API.
     6  ---
     7  
     8  # VMware Builder (from ISO)
     9  
    10  Type: `vmware-iso`
    11  
    12  This VMware Packer builder is able to create VMware virtual machines from an
    13  ISO file as a source. It currently
    14  supports building virtual machines on hosts running
    15  [VMware Fusion](http://www.vmware.com/products/fusion/overview.html) for OS X,
    16  [VMware Workstation](http://www.vmware.com/products/workstation/overview.html)
    17  for Linux and Windows, and
    18  [VMware Player](http://www.vmware.com/products/player/) on Linux. It can
    19  also build machines directly on
    20  [VMware vSphere Hypervisor](http://www.vmware.com/products/vsphere-hypervisor/)
    21  using SSH as opposed to the vSphere API.
    22  
    23  The builder builds a virtual machine by creating a new virtual machine
    24  from scratch, booting it, installing an OS, provisioning software within
    25  the OS, then shutting it down. The result of the VMware builder is a directory
    26  containing all the files necessary to run the virtual machine.
    27  
    28  ## Basic Example
    29  
    30  Here is a basic example. This example is not functional. It will start the
    31  OS installer but then fail because we don't provide the preseed file for
    32  Ubuntu to self-install. Still, the example serves to show the basic configuration:
    33  
    34  ```javascript
    35  {
    36    "type": "vmware-iso",
    37    "iso_url": "http://old-releases.ubuntu.com/releases/precise/ubuntu-12.04.2-server-amd64.iso",
    38    "iso_checksum": "af5f788aee1b32c4b2634734309cc9e9",
    39    "iso_checksum_type": "md5",
    40    "ssh_username": "packer",
    41    "ssh_wait_timeout": "30s",
    42    "shutdown_command": "shutdown -P now"
    43  }
    44  ```
    45  
    46  ## Configuration Reference
    47  
    48  There are many configuration options available for the VMware builder.
    49  They are organized below into two categories: required and optional. Within
    50  each category, the available options are alphabetized and described.
    51  
    52  ### Required:
    53  
    54  * `iso_checksum` (string) - The checksum for the OS ISO file. Because ISO
    55    files are so large, this is required and Packer will verify it prior
    56    to booting a virtual machine with the ISO attached. The type of the
    57    checksum is specified with `iso_checksum_type`, documented below.
    58  
    59  * `iso_checksum_type` (string) - The type of the checksum specified in
    60    `iso_checksum`. Valid values are "none", "md5", "sha1", "sha256", or
    61    "sha512" currently. While "none" will skip checksumming, this is not
    62    recommended since ISO files are generally large and corruption does happen
    63    from time to time.
    64  
    65  * `iso_url` (string) - A URL to the ISO containing the installation image.
    66    This URL can be either an HTTP URL or a file URL (or path to a file).
    67    If this is an HTTP URL, Packer will download it and cache it between
    68    runs.
    69  
    70  * `ssh_username` (string) - The username to use to SSH into the machine
    71    once the OS is installed.
    72  
    73  ### Optional:
    74  
    75  * `boot_command` (array of strings) - This is an array of commands to type
    76    when the virtual machine is firsted booted. The goal of these commands should
    77    be to type just enough to initialize the operating system installer. Special
    78    keys can be typed as well, and are covered in the section below on the boot
    79    command. If this is not specified, it is assumed the installer will start
    80    itself.
    81  
    82  * `boot_wait` (string) - The time to wait after booting the initial virtual
    83    machine before typing the `boot_command`. The value of this should be
    84    a duration. Examples are "5s" and "1m30s" which will cause Packer to wait
    85    five seconds and one minute 30 seconds, respectively. If this isn't specified,
    86    the default is 10 seconds.
    87  
    88  * `disk_size` (integer) - The size of the hard disk for the VM in megabytes.
    89    The builder uses expandable, not fixed-size virtual hard disks, so the
    90    actual file representing the disk will not use the full size unless it is full.
    91    By default this is set to 40,000 (about 40 GB).
    92  
    93  * `disk_type_id` (string) - The type of VMware virtual disk to create.
    94    The default is "1", which corresponds to a growable virtual disk split in
    95    2GB files.  This option is for advanced usage, modify only if you
    96    know what you're doing.  For more information, please consult the
    97    [Virtual Disk Manager User's Guide](http://www.vmware.com/pdf/VirtualDiskManager.pdf)
    98    for desktop VMware clients. For ESXi, refer to the proper ESXi documentation.
    99  
   100  * `floppy_files` (array of strings) - A list of files to place onto a floppy
   101    disk that is attached when the VM is booted. This is most useful
   102    for unattended Windows installs, which look for an `Autounattend.xml` file
   103    on removable media. By default, no floppy will be attached. All files
   104    listed in this setting get placed into the root directory of the floppy
   105    and the floppy is attached as the first floppy device. Currently, no
   106    support exists for creating sub-directories on the floppy. Wildcard
   107    characters (*, ?, and []) are allowed. Directory names are also allowed,
   108    which will add all the files found in the directory to the floppy.
   109  
   110  * `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this
   111    is "/Applications/VMware Fusion.app" but this setting allows you to
   112    customize this.
   113  
   114  * `guest_os_type` (string) - The guest OS type being installed. This will be
   115    set in the VMware VMX. By default this is "other". By specifying a more specific
   116    OS type, VMware may perform some optimizations or virtual hardware changes
   117    to better support the operating system running in the virtual machine.
   118  
   119  * `headless` (boolean) - Packer defaults to building VMware
   120    virtual machines by launching a GUI that shows the console of the
   121    machine being built. When this value is set to true, the machine will
   122    start without a console. For VMware machines, Packer will output VNC
   123    connection information in case you need to connect to the console to
   124    debug the build process.
   125  
   126  * `http_directory` (string) - Path to a directory to serve using an HTTP
   127    server. The files in this directory will be available over HTTP that will
   128    be requestable from the virtual machine. This is useful for hosting
   129    kickstart files and so on. By default this is "", which means no HTTP
   130    server will be started. The address and port of the HTTP server will be
   131    available as variables in `boot_command`. This is covered in more detail
   132    below.
   133  
   134  * `http_port_min` and `http_port_max` (integer) - These are the minimum and
   135    maximum port to use for the HTTP server started to serve the `http_directory`.
   136    Because Packer often runs in parallel, Packer will choose a randomly available
   137    port in this range to run the HTTP server. If you want to force the HTTP
   138    server to be on one port, make this minimum and maximum port the same.
   139    By default the values are 8000 and 9000, respectively.
   140  
   141  * `iso_urls` (array of strings) - Multiple URLs for the ISO to download.
   142    Packer will try these in order. If anything goes wrong attempting to download
   143    or while downloading a single URL, it will move on to the next. All URLs
   144    must point to the same file (same checksum). By default this is empty
   145    and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be specified.
   146  
   147  * `output_directory` (string) - This is the path to the directory where the
   148    resulting virtual machine will be created. This may be relative or absolute.
   149    If relative, the path is relative to the working directory when `packer`
   150    is executed. This directory must not exist or be empty prior to running the builder.
   151    By default this is "output-BUILDNAME" where "BUILDNAME" is the name
   152    of the build.
   153  
   154  * `remote_cache_datastore` (string) - The path to the datastore where
   155    supporting files will be stored during the build on the remote machine.
   156    By default this is the same as the `remote_datastore` option. This only
   157    has an effect if `remote_type` is enabled.
   158  
   159  * `remote_cache_directory` (string) - The path where the ISO and/or floppy
   160    files will be stored during the build on the remote machine. The path is
   161    relative to the `remote_cache_datastore` on the remote machine.  By default
   162    this is "packer_cache". This only has an effect if `remote_type` is enabled.
   163  
   164  * `remote_datastore` (string) - The path to the datastore where the resulting
   165    VM will be stored when it is built on the remote machine. By default this
   166    is "datastore1". This only has an effect if `remote_type` is enabled.
   167  
   168  * `remote_host` (string) - The host of the remote machine used for access.
   169    This is only required if `remote_type` is enabled.
   170  
   171  * `remote_password` (string) - The SSH password for the user used to
   172    access the remote machine. By default this is empty. This only has an
   173    effect if `remote_type` is enabled.
   174  
   175  * `remote_type` (string) - The type of remote machine that will be used to
   176    build this VM rather than a local desktop product. The only value accepted
   177    for this currently is "esx5". If this is not set, a desktop product will be
   178    used. By default, this is not set.
   179  
   180  * `remote_username` (string) - The username for the SSH user that will access
   181    the remote machine. This is required if `remote_type` is enabled.
   182  
   183  * `shutdown_command` (string) - The command to use to gracefully shut down
   184    the machine once all the provisioning is done. By default this is an empty
   185    string, which tells Packer to just forcefully shut down the machine.
   186  
   187  * `shutdown_timeout` (string) - The amount of time to wait after executing
   188    the `shutdown_command` for the virtual machine to actually shut down.
   189    If it doesn't shut down in this time, it is an error. By default, the timeout
   190    is "5m", or five minutes.
   191  
   192  * `skip_compaction` (boolean) -  VMware-created disks are defragmented
   193    and compacted at the end of the build process using `vmware-vdiskmanager`.
   194    In certain rare cases, this might actually end up making the resulting disks
   195    slightly larger. If you find this to be the case, you can disable compaction
   196    using this configuration value.
   197  
   198  * `ssh_host` (string) - Hostname or IP address of the host. By default, DHCP
   199    is used to connect to the host and this field is not used.
   200  
   201  * `ssh_key_path` (string) - Path to a private key to use for authenticating
   202    with SSH. By default this is not set (key-based auth won't be used).
   203    The associated public key is expected to already be configured on the
   204    VM being prepared by some other process (kickstart, etc.).
   205  
   206  * `ssh_password` (string) - The password for `ssh_username` to use to
   207    authenticate with SSH. By default this is the empty string.
   208  
   209  * `ssh_port` (integer) - The port that SSH will listen on within the virtual
   210    machine. By default this is 22.
   211  
   212  * `ssh_skip_request_pty` (boolean) - If true, a pty will not be requested as
   213    part of the SSH connection. By default, this is "false", so a pty
   214    _will_ be requested.
   215  
   216  * `ssh_wait_timeout` (string) - The duration to wait for SSH to become
   217    available. By default this is "20m", or 20 minutes. Note that this should
   218    be quite long since the timer begins as soon as the virtual machine is booted.
   219  
   220  * `tools_upload_flavor` (string) - The flavor of the VMware Tools ISO to
   221    upload into the VM. Valid values are "darwin", "linux", and "windows".
   222    By default, this is empty, which means VMware tools won't be uploaded.
   223  
   224  * `tools_upload_path` (string) - The path in the VM to upload the VMware
   225    tools. This only takes effect if `tools_upload_flavor` is non-empty.
   226    This is a [configuration template](/docs/templates/configuration-templates.html)
   227    that has a single valid variable: `Flavor`, which will be the value of
   228    `tools_upload_flavor`. By default the upload path is set to
   229    `{{.Flavor}}.iso`.
   230  
   231  * `version` (string) - The [vmx hardware version](http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003746) for the new virtual machine.  Only the default value has been tested, any other value is experimental.  Default value is '9'.
   232  
   233  * `vm_name` (string) - This is the name of the VMX file for the new virtual
   234    machine, without the file extension. By default this is "packer-BUILDNAME",
   235    where "BUILDNAME" is the name of the build.
   236  
   237  * `vmdk_name` (string) - The filename of the virtual disk that'll be created,
   238    without the extension. This defaults to "packer".
   239  
   240  * `vmx_data` (object of key/value strings) - Arbitrary key/values
   241    to enter into the virtual machine VMX file. This is for advanced users
   242    who want to set properties such as memory, CPU, etc.
   243  
   244  * `vmx_data_post` (object of key/value strings) - Identical to `vmx_data`,
   245    except that it is run after the virtual machine is shutdown, and before the
   246    virtual machine is exported.
   247  
   248  * `vmx_template_path` (string) - Path to a
   249    [configuration template](/docs/templates/configuration-templates.html) that
   250    defines the contents of the virtual machine VMX file for VMware. This is
   251    for **advanced users only** as this can render the virtual machine
   252    non-functional. See below for more information. For basic VMX modifications,
   253    try `vmx_data` first.
   254  
   255  * `vnc_port_min` and `vnc_port_max` (integer) - The minimum and maximum port to
   256    use for VNC access to the virtual machine. The builder uses VNC to type
   257    the initial `boot_command`. Because Packer generally runs in parallel, Packer
   258    uses a randomly chosen port in this range that appears available. By default
   259    this is 5900 to 6000. The minimum and maximum ports are inclusive.
   260  
   261  ## Boot Command
   262  
   263  The `boot_command` configuration is very important: it specifies the keys
   264  to type when the virtual machine is first booted in order to start the
   265  OS installer. This command is typed after `boot_wait`, which gives the
   266  virtual machine some time to actually load the ISO.
   267  
   268  As documented above, the `boot_command` is an array of strings. The
   269  strings are all typed in sequence. It is an array only to improve readability
   270  within the template.
   271  
   272  The boot command is "typed" character for character over a VNC connection
   273  to the machine, simulating a human actually typing the keyboard. There are
   274  a set of special keys available. If these are in your boot command, they
   275  will be replaced by the proper key:
   276  
   277  * `<bs>` - Backspace
   278  
   279  * `<del>` - Delete
   280  
   281  * `<enter>` and `<return>` - Simulates an actual "enter" or "return" keypress.
   282  
   283  * `<esc>` - Simulates pressing the escape key.
   284  
   285  * `<tab>` - Simulates pressing the tab key.
   286  
   287  * `<f1>` - `<f12>` - Simulates pressing a function key.
   288  
   289  * `<up>` `<down>` `<left>` `<right>` - Simulates pressing an arrow key.
   290  
   291  * `<spacebar>` - Simulates pressing the spacebar.
   292  
   293  * `<insert>` - Simulates pressing the insert key.
   294  
   295  * `<home>` `<end>` - Simulates pressing the home and end keys.
   296  
   297  * `<pageUp>` `<pageDown>` - Simulates pressing the page up and page down keys.
   298  
   299  * `<wait>` `<wait5>` `<wait10>` - Adds a 1, 5 or 10 second pause before sending any additional keys. This
   300    is useful if you have to generally wait for the UI to update before typing more.
   301  
   302  In addition to the special keys, each command to type is treated as a
   303  [configuration template](/docs/templates/configuration-templates.html).
   304  The available variables are:
   305  
   306  * `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server
   307    that is started serving the directory specified by the `http_directory`
   308    configuration parameter. If `http_directory` isn't specified, these will
   309    be blank!
   310  
   311  Example boot command. This is actually a working boot command used to start
   312  an Ubuntu 12.04 installer:
   313  
   314  ```javascript
   315  [
   316    "&lt;esc&gt;&lt;esc&gt;&lt;enter&gt;&lt;wait&gt;",
   317    "/install/vmlinuz noapic ",
   318    "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
   319    "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
   320    "hostname={{ .Name }} ",
   321    "fb=false debconf/frontend=noninteractive ",
   322    "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
   323    "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
   324    "initrd=/install/initrd.gz -- &lt;enter&gt;"
   325  ]
   326  ```
   327  
   328  ## VMX Template
   329  
   330  The heart of a VMware machine is the "vmx" file. This contains all the
   331  virtual hardware metadata necessary for the VM to function. Packer by default
   332  uses a [safe, flexible VMX file](https://github.com/mitchellh/packer/blob/20541a7eda085aa5cf35bfed5069592ca49d106e/builder/vmware/step_create_vmx.go#L84).
   333  But for advanced users, this template can be customized. This allows
   334  Packer to build virtual machines of effectively any guest operating system
   335  type.
   336  
   337  ~> **This is an advanced feature.** Modifying the VMX template
   338  can easily cause your virtual machine to not boot properly. Please only
   339  modify the template if you know what you're doing.
   340  
   341  Within the template, a handful of variables are available so that your
   342  template can continue working with the rest of the Packer machinery. Using
   343  these variables isn't required, however.
   344  
   345  * `Name` - The name of the virtual machine.
   346  * `GuestOS` - The VMware-valid guest OS type.
   347  * `DiskName` - The filename (without the suffix) of the main virtual disk.
   348  * `ISOPath` - The path to the ISO to use for the OS installation.
   349  * `Version` - The Hardware version VMWare will execute this vm under.  Also known as the `virtualhw.version`.
   350  
   351  ## Building on a Remote vSphere Hypervisor
   352  
   353  In addition to using the desktop products of VMware locally to build
   354  virtual machines, Packer can use a remote VMware Hypervisor to build
   355  the virtual machine.
   356  
   357  -> **Note:** Packer supports ESXi 5.1 and above.
   358  
   359  Before using a remote vSphere Hypervisor, you need to enable GuestIPHack by running the following command:
   360  
   361  ```text
   362  esxcli system settings advanced set -o /Net/GuestIPHack -i 1
   363  ```
   364  
   365  When using a remote VMware Hypervisor, the builder still downloads the
   366  ISO and various files locally, and uploads these to the remote machine.
   367  Packer currently uses SSH to communicate to the ESXi machine rather than
   368  the vSphere API. At some point, the vSphere API may be used.
   369  
   370  Packer also requires VNC to issue boot commands during a build,
   371  which may be disabled on some remote VMware Hypervisors.  Please consult
   372  the appropriate documentation on how to update VMware Hypervisor's firewall
   373  to allow these connections.
   374  
   375  To use a remote VMware vSphere Hypervisor to build your virtual machine,
   376  fill in the required `remote_*` configurations:
   377  
   378  * `remote_type` - This must be set to "esx5".
   379  
   380  * `remote_host` - The host of the remote machine.
   381  
   382  Additionally, there are some optional configurations that you'll likely
   383  have to modify as well:
   384  
   385  * `remote_datastore` - The path to the datastore where the VM will be
   386    stored on the ESXi machine.
   387  
   388  * `remote_cache_datastore` - The path to the datastore where
   389    supporting files will be stored during the build on the remote machine.
   390  
   391  * `remote_cache_directory` - The path where the ISO and/or floppy
   392    files will be stored during the build on the remote machine. The path is
   393    relative to the `remote_cache_datastore` on the remote machine.
   394  
   395  * `remote_username` - The SSH username used to access the remote machine.
   396  
   397  * `remote_password` - The SSH password for access to the remote machine.