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