github.com/phobos182/packer@v0.2.3-0.20130819023704-c84d2aeffc68/website/source/docs/builders/vmware.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  ---
     4  
     5  # VMware Builder
     6  
     7  Type: `vmware`
     8  
     9  The VMware builder is able to create VMware virtual machines. It currently
    10  supports building virtual machines on hosts running
    11  [VMware Fusion](http://www.vmware.com/products/fusion/overview.html) for OS X,
    12  [VMware Workstation](http://www.vmware.com/products/workstation/overview.html)
    13  for Linux and Windows, and
    14  [VMware Player](http://www.vmware.com/products/player/) on Linux.
    15  
    16  The builder builds a virtual machine by creating a new virtual machine
    17  from scratch, booting it, installing an OS, provisioning software within
    18  the OS, then shutting it down. The result of the VMware builder is a directory
    19  containing all the files necessary to run the virtual machine.
    20  
    21  ## Basic Example
    22  
    23  Here is a basic example. This example is not functional. It will start the
    24  OS installer but then fail because we don't provide the preseed file for
    25  Ubuntu to self-install. Still, the example serves to show the basic configuration:
    26  
    27  <pre class="prettyprint">
    28  {
    29    "type": "vmware",
    30    "iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.2-server-amd64.iso",
    31    "iso_checksum": "af5f788aee1b32c4b2634734309cc9e9",
    32    "iso_checksum_type": "md5",
    33    "ssh_username": "packer",
    34    "ssh_wait_timeout": "30s",
    35    "shutdown_command": "shutdown -P now"
    36  }
    37  </pre>
    38  
    39  ## Configuration Reference
    40  
    41  There are many configuration options available for the VMware builder.
    42  They are organized below into two categories: required and optional. Within
    43  each category, the available options are alphabetized and described.
    44  
    45  Required:
    46  
    47  * `iso_checksum` (string) - The checksum for the OS ISO file. Because ISO
    48    files are so large, this is required and Packer will verify it prior
    49    to booting a virtual machine with the ISO attached. The type of the
    50    checksum is specified with `iso_checksum_type`, documented below.
    51  
    52  * `iso_checksum_type` (string) - The type of the checksum specified in
    53    `iso_checksum`. Valid values are "md5", "sha1", or "sha256" currently.
    54  
    55  * `iso_url` (string) - A URL to the ISO containing the installation image.
    56    This URL can be either an HTTP URL or a file URL (or path to a file).
    57    If this is an HTTP URL, Packer will download it and cache it between
    58    runs.
    59  
    60  * `ssh_username` (string) - The username to use to SSH into the machine
    61    once the OS is installed.
    62  
    63  Optional:
    64  
    65  * `boot_command` (array of strings) - This is an array of commands to type
    66    when the virtual machine is firsted booted. The goal of these commands should
    67    be to type just enough to initialize the operating system installer. Special
    68    keys can be typed as well, and are covered in the section below on the boot
    69    command. If this is not specified, it is assumed the installer will start
    70    itself.
    71  
    72  * `boot_wait` (string) - The time to wait after booting the initial virtual
    73    machine before typing the `boot_command`. The value of this should be
    74    a duration. Examples are "5s" and "1m30s" which will cause Packer to wait
    75    five seconds and one minute 30 seconds, respectively. If this isn't specified,
    76    the default is 10 seconds.
    77  
    78  * `disk_size` (int) - The size of the hard disk for the VM in megabytes.
    79    The builder uses expandable, not fixed-size virtual hard disks, so the
    80    actual file representing the disk will not use the full size unless it is full.
    81    By default this is set to 40,000 (40 GB).
    82  
    83  * `floppy_files` (array of strings) - A list of files to put onto a floppy
    84    disk that is attached when the VM is booted for the first time. This is
    85    most useful for unattended Windows installs, which look for an
    86    `Autounattend.xml` file on removable media. By default no floppy will
    87    be attached. The files listed in this configuration will all be put
    88    into the root directory of the floppy disk; sub-directories are not supported.
    89  
    90  * `guest_os_type` (string) - The guest OS type being installed. This will be
    91    set in the VMware VMX. By default this is "other". By specifying a more specific
    92    OS type, VMware may perform some optimizations or virtual hardware changes
    93    to better support the operating system running in the virtual machine.
    94  
    95  * `headless` (bool) - Packer defaults to building VMware
    96    virtual machines by launching a GUI that shows the console of the
    97    machine being built. When this value is set to true, the machine will
    98    start without a console. For VMware machines, Packer will output VNC
    99    connection information in case you need to connect to the console to
   100    debug the build process.
   101  
   102  * `http_directory` (string) - Path to a directory to serve using an HTTP
   103    server. The files in this directory will be available over HTTP that will
   104    be requestable from the virtual machine. This is useful for hosting
   105    kickstart files and so on. By default this is "", which means no HTTP
   106    server will be started. The address and port of the HTTP server will be
   107    available as variables in `boot_command`. This is covered in more detail
   108    below.
   109  
   110  * `http_port_min` and `http_port_max` (int) - These are the minimum and
   111    maximum port to use for the HTTP server started to serve the `http_directory`.
   112    Because Packer often runs in parallel, Packer will choose a randomly available
   113    port in this range to run the HTTP server. If you want to force the HTTP
   114    server to be on one port, make this minimum and maximum port the same.
   115    By default the values are 8000 and 9000, respectively.
   116  
   117  * `iso_urls` (array of strings) - Multiple URLs for the ISO to download.
   118    Packer will try these in order. If anything goes wrong attempting to download
   119    or while downloading a single URL, it will move on to the next. All URLs
   120    must point to the same file (same checksum). By default this is empty
   121    and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be specified.
   122  
   123  * `output_directory` (string) - This is the path to the directory where the
   124    resulting virtual machine will be created. This may be relative or absolute.
   125    If relative, the path is relative to the working directory when `packer`
   126    is executed. This directory must not exist or be empty prior to running the builder.
   127    By default this is "output-BUILDNAME" where "BUILDNAME" is the name
   128    of the build.
   129  
   130  * `skip_compaction` (bool) -  VMware-created disks are defragmented
   131    and compacted at the end of the build process using `vmware-vdiskmanager`.
   132    In certain rare cases, this might actually end up making the resulting disks
   133    slightly larger. If you find this to be the case, you can disable compaction
   134    using this configuration value.
   135  
   136  * `shutdown_command` (string) - The command to use to gracefully shut down
   137    the machine once all the provisioning is done. By default this is an empty
   138    string, which tells Packer to just forcefully shut down the machine.
   139  
   140  * `shutdown_timeout` (string) - The amount of time to wait after executing
   141    the `shutdown_command` for the virtual machine to actually shut down.
   142    If it doesn't shut down in this time, it is an error. By default, the timeout
   143    is "5m", or five minutes.
   144  
   145  * `ssh_password` (string) - The password for `ssh_username` to use to
   146    authenticate with SSH. By default this is the empty string.
   147  
   148  * `ssh_port` (int) - The port that SSH will listen on within the virtual
   149    machine. By default this is 22.
   150  
   151  * `ssh_wait_timeout` (string) - The duration to wait for SSH to become
   152    available. By default this is "20m", or 20 minutes. Note that this should
   153    be quite long since the timer begins as soon as the virtual machine is booted.
   154  
   155  * `tools_upload_flavor` (string) - The flavor of the VMware Tools ISO to
   156    upload into the VM. Valid values are "darwin", "linux", and "windows".
   157    By default, this is empty, which means VMware tools won't be uploaded.
   158  
   159  * `tools_upload_path` (string) - The path in the VM to upload the VMware
   160    tools. This only takes effect if `tools_upload_flavor` is non-empty.
   161    This is a [configuration template](/docs/templates/configuration-templates.html)
   162    that has a single valid variable: `Flavor`, which will be the value of
   163    `tools_upload_flavor`. By default the upload path is set to
   164    `{{.Flavor}}.iso`.
   165  
   166  * `vm_name` (string) - This is the name of the VMX file for the new virtual
   167    machine, without the file extension. By default this is "packer-BUILDNAME",
   168    where "BUILDNAME" is the name of the build.
   169  
   170  * `vmdk_name` (string) - The filename of the virtual disk that'll be created,
   171    without the extension. This defaults to "packer".
   172  
   173  * `vmx_data` (object, string keys and string values) - Arbitrary key/values
   174    to enter into the virtual machine VMX file. This is for advanced users
   175    who want to set properties such as memory, CPU, etc.
   176  
   177  * `vnc_port_min` and `vnc_port_max` (int) - The minimum and maximum port to
   178    use for VNC access to the virtual machine. The builder uses VNC to type
   179    the initial `boot_command`. Because Packer generally runs in parallel, Packer
   180    uses a randomly chosen port in this range that appears available. By default
   181    this is 5900 to 6000. The minimum and maximum ports are inclusive.
   182  
   183  ## Boot Command
   184  
   185  The `boot_command` configuration is very important: it specifies the keys
   186  to type when the virtual machine is first booted in order to start the
   187  OS installer. This command is typed after `boot_wait`, which gives the
   188  virtual machine some time to actually load the ISO.
   189  
   190  As documented above, the `boot_command` is an array of strings. The
   191  strings are all typed in sequence. It is an array only to improve readability
   192  within the template.
   193  
   194  The boot command is "typed" character for character over a VNC connection
   195  to the machine, simulating a human actually typing the keyboard. There are
   196  a set of special keys available. If these are in your boot command, they
   197  will be replaced by the proper key:
   198  
   199  * `<enter>` and `<return>` - Simulates an actual "enter" or "return" keypress.
   200  
   201  * `<esc>` - Simulates pressing the escape key.
   202  
   203  * `<tab>` - Simulates pressing the tab key.
   204  
   205  * `<wait>` `<wait5>` `<wait10>` - Adds a 1, 5 or 10 second pause before sending any additional keys. This
   206    is useful if you have to generally wait for the UI to update before typing more.
   207  
   208  In addition to the special keys, each command to type is treated as a
   209  [configuration template](/docs/templates/configuration-templates.html).
   210  The available variables are:
   211  
   212  * `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server
   213    that is started serving the directory specified by the `http_directory`
   214    configuration parameter. If `http_directory` isn't specified, these will
   215    be blank!
   216  
   217  Example boot command. This is actually a working boot command used to start
   218  an Ubuntu 12.04 installer:
   219  
   220  <pre class="prettyprint">
   221  [
   222    "&lt;esc&gt;&lt;esc&gt;&lt;enter&gt;&lt;wait&gt;",
   223    "/install/vmlinuz noapic ",
   224    "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
   225    "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
   226    "hostname={{ .Name }} ",
   227    "fb=false debconf/frontend=noninteractive ",
   228    "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
   229    "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
   230    "initrd=/install/initrd.gz -- &lt;enter&gt;"
   231  ]
   232  </pre>