github.com/amanya/packer@v0.12.1-0.20161117214323-902ac5ab2eb6/website/source/docs/builders/vmware-vmx.html.md (about)

     1  ---
     2  description: |
     3      This VMware Packer builder is able to create VMware virtual machines from an
     4      existing VMware virtual machine (a VMX file). It currently supports building
     5      virtual machines on hosts running VMware Fusion Professional for OS X, VMware
     6      Workstation for Linux and Windows, and VMware Player on Linux.
     7  layout: docs
     8  page_title: VMware Builder from VMX
     9  ...
    10  
    11  # VMware Builder (from VMX)
    12  
    13  Type: `vmware-vmx`
    14  
    15  This VMware Packer builder is able to create VMware virtual machines from an
    16  existing VMware virtual machine (a VMX file). It currently supports building
    17  virtual machines on hosts running [VMware Fusion
    18  Professional](https://www.vmware.com/products/fusion-professional/) for OS X,
    19  [VMware Workstation](https://www.vmware.com/products/workstation/overview.html)
    20  for Linux and Windows, and [VMware
    21  Player](https://www.vmware.com/products/player/) on Linux.
    22  
    23  The builder builds a virtual machine by cloning the VMX file using the clone
    24  capabilities introduced in VMware Fusion Professional 6, Workstation 10, and
    25  Player 6. After cloning the VM, it provisions software within the new machine,
    26  shuts it down, and compacts the disks. The resulting folder contains a new
    27  VMware virtual machine.
    28  
    29  ## Basic Example
    30  
    31  Here is an example. This example is fully functional as long as the source path
    32  points to a real VMX file with the proper settings:
    33  
    34  ``` {.javascript}
    35  {
    36    "type": "vmware-vmx",
    37    "source_path": "/path/to/a/vm.vmx",
    38    "ssh_username": "root",
    39    "ssh_password": "root",
    40    "shutdown_command": "shutdown -P now"
    41  }
    42  ```
    43  
    44  ## Configuration Reference
    45  
    46  There are many configuration options available for the VMware builder. They are
    47  organized below into two categories: required and optional. Within each
    48  category, the available options are alphabetized and described.
    49  
    50  In addition to the options listed here, a
    51  [communicator](/docs/templates/communicator.html) can be configured for this
    52  builder.
    53  
    54  ### Required:
    55  
    56  -   `source_path` (string) - Path to the source VMX file to clone.
    57  
    58  -   `ssh_username` (string) - The username to use to SSH into the machine once
    59      the OS is installed.
    60  
    61  ### Optional:
    62  
    63  -   `boot_command` (array of strings) - This is an array of commands to type
    64      when the virtual machine is first booted. The goal of these commands should
    65      be to type just enough to initialize the operating system installer. Special
    66      keys can be typed as well, and are covered in the section below on the
    67      boot command. If this is not specified, it is assumed the installer will
    68      start itself.
    69  
    70  -   `boot_wait` (string) - The time to wait after booting the initial virtual
    71      machine before typing the `boot_command`. The value of this should be
    72      a duration. Examples are "5s" and "1m30s" which will cause Packer to wait
    73      five seconds and one minute 30 seconds, respectively. If this isn't
    74      specified, the default is 10 seconds.
    75  
    76  -   `floppy_files` (array of strings) - A list of files to place onto a floppy
    77      disk that is attached when the VM is booted. This is most useful for
    78      unattended Windows installs, which look for an `Autounattend.xml` file on
    79      removable media. By default, no floppy will be attached. All files listed in
    80      this setting get placed into the root directory of the floppy and the floppy
    81      is attached as the first floppy device. Currently, no support exists for
    82      creating sub-directories on the floppy. Wildcard characters (\*, ?,
    83      and \[\]) are allowed. Directory names are also allowed, which will add all
    84      the files found in the directory to the floppy.
    85  
    86  -   `floppy_dirs` (array of strings) - A list of directories to place onto
    87      the floppy disk recursively. This is similar to the `floppy_files` option
    88      except that the directory structure is preserved. This is useful for when
    89      your floppy disk includes drivers or if you just want to organize it's 
    90      contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
    91  
    92  -   `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this is
    93      "/Applications/VMware Fusion.app" but this setting allows you to
    94      customize this.
    95  
    96  -   `headless` (boolean) - Packer defaults to building VMware virtual machines
    97      by launching a GUI that shows the console of the machine being built. When
    98      this value is set to true, the machine will start without a console. For
    99      VMware machines, Packer will output VNC connection information in case you
   100      need to connect to the console to debug the build process.
   101  
   102  -   `http_directory` (string) - Path to a directory to serve using an
   103      HTTP server. The files in this directory will be available over HTTP that
   104      will 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 server
   106      will be started. The address and port of the HTTP server will be available
   107      as variables in `boot_command`. This is covered in more detail below.
   108  
   109  -   `http_port_min` and `http_port_max` (integer) - These are the minimum and
   110      maximum port to use for the HTTP server started to serve the
   111      `http_directory`. Because Packer often runs in parallel, Packer will choose
   112      a randomly available port in this range to run the HTTP server. If you want
   113      to force the HTTP server to be on one port, make this minimum and maximum
   114      port the same. By default the values are 8000 and 9000, respectively.
   115  
   116  -   `output_directory` (string) - This is the path to the directory where the
   117      resulting virtual machine will be created. This may be relative or absolute.
   118      If relative, the path is relative to the working directory when `packer`
   119      is executed. This directory must not exist or be empty prior to running
   120      the builder. By default this is "output-BUILDNAME" where "BUILDNAME" is the
   121      name of the build.
   122  
   123  -   `shutdown_command` (string) - The command to use to gracefully shut down the
   124      machine once all the provisioning is done. By default this is an empty
   125      string, which tells Packer to just forcefully shut down the machine unless a
   126      shutdown command takes place inside script so this may safely be omitted. If
   127      one or more scripts require a reboot it is suggested to leave this blank
   128      since reboots may fail and specify the final shutdown command in your
   129      last script.
   130  
   131  -   `shutdown_timeout` (string) - The amount of time to wait after executing the
   132      `shutdown_command` for the virtual machine to actually shut down. If it
   133      doesn't shut down in this time, it is an error. By default, the timeout is
   134      "5m", or five minutes.
   135  
   136  -   `skip_compaction` (boolean) - VMware-created disks are defragmented and
   137      compacted at the end of the build process using `vmware-vdiskmanager`. In
   138      certain rare cases, this might actually end up making the resulting disks
   139      slightly larger. If you find this to be the case, you can disable compaction
   140      using this configuration value.
   141  
   142  -   `tools_upload_flavor` (string) - The flavor of the VMware Tools ISO to
   143      upload into the VM. Valid values are "darwin", "linux", and "windows". By
   144      default, this is empty, which means VMware tools won't be uploaded.
   145  
   146  -   `tools_upload_path` (string) - The path in the VM to upload the
   147      VMware tools. This only takes effect if `tools_upload_flavor` is non-empty.
   148      This is a [configuration
   149      template](/docs/templates/configuration-templates.html) that has a single
   150      valid variable: `Flavor`, which will be the value of `tools_upload_flavor`.
   151      By default the upload path is set to `{{.Flavor}}.iso`.
   152  
   153  -   `vm_name` (string) - This is the name of the VMX file for the new virtual
   154      machine, without the file extension. By default this is "packer-BUILDNAME",
   155      where "BUILDNAME" is the name of the build.
   156  
   157  -   `vmx_data` (object of key/value strings) - Arbitrary key/values to enter
   158      into the virtual machine VMX file. This is for advanced users who want to
   159      set properties such as memory, CPU, etc.
   160  
   161  -   `vmx_data_post` (object of key/value strings) - Identical to `vmx_data`,
   162      except that it is run after the virtual machine is shutdown, and before the
   163      virtual machine is exported.
   164  
   165  -   `vnc_bind_address` (string / IP address) - The IP address that should be binded
   166       to for VNC. By default packer will use 127.0.0.1 for this.
   167  
   168  -   `vnc_disable_password` (boolean) - Don't auto-generate a VNC password that is
   169      used to secure the VNC communication with the VM.
   170  
   171  -   `vnc_port_min` and `vnc_port_max` (integer) - The minimum and maximum port
   172      to use for VNC access to the virtual machine. The builder uses VNC to type
   173      the initial `boot_command`. Because Packer generally runs in parallel,
   174      Packer uses a randomly chosen port in this range that appears available. By
   175      default this is 5900 to 6000. The minimum and maximum ports are inclusive.
   176  
   177  ## Boot Command
   178  
   179  The `boot_command` configuration is very important: it specifies the keys to
   180  type when the virtual machine is first booted in order to start the OS
   181  installer. This command is typed after `boot_wait`.
   182  
   183  As documented above, the `boot_command` is an array of strings. The strings are
   184  all typed in sequence. It is an array only to improve readability within the
   185  template.
   186  
   187  The boot command is "typed" character for character over a VNC connection to the
   188  machine, simulating a human actually typing the keyboard. There are a set of
   189  special keys available. If these are in your boot command, they will be replaced
   190  by the proper key:
   191  
   192  -   `<bs>` - Backspace
   193  
   194  -   `<del>` - Delete
   195  
   196  -   `<enter>` and `<return>` - Simulates an actual "enter" or "return" keypress.
   197  
   198  -   `<esc>` - Simulates pressing the escape key.
   199  
   200  -   `<tab>` - Simulates pressing the tab key.
   201  
   202  -   `<f1>` - `<f12>` - Simulates pressing a function key.
   203  
   204  -   `<up>` `<down>` `<left>` `<right>` - Simulates pressing an arrow key.
   205  
   206  -   `<spacebar>` - Simulates pressing the spacebar.
   207  
   208  -   `<insert>` - Simulates pressing the insert key.
   209  
   210  -   `<home>` `<end>` - Simulates pressing the home and end keys.
   211  
   212  -   `<pageUp>` `<pageDown>` - Simulates pressing the page up and page down keys.
   213  
   214  -   `<leftAlt>` `<rightAlt>`  - Simulates pressing the alt key.
   215  
   216  -   `<leftCtrl>` `<rightCtrl>` - Simulates pressing the ctrl key.
   217  
   218  -   `<leftShift>` `<rightShift>` - Simulates pressing the shift key.
   219  
   220  -   `<leftAltOn>` `<rightAltOn>`  - Simulates pressing and holding the alt key.
   221  
   222  -   `<leftCtrlOn>` `<rightCtrlOn>` - Simulates pressing and holding the ctrl 
   223      key. 
   224  
   225  -   `<leftShiftOn>` `<rightShiftOn>` - Simulates pressing and holding the 
   226      shift key.
   227  
   228  -   `<leftAltOff>` `<rightAltOff>`  - Simulates releasing a held alt key.
   229  
   230  -   `<leftCtrlOff>` `<rightCtrlOff>` - Simulates releasing a held ctrl key.
   231  
   232  -   `<leftShiftOff>` `<rightShiftOff>` - Simulates releasing a held shift key.
   233  
   234  -   `<wait>` `<wait5>` `<wait10>` - Adds a 1, 5 or 10 second pause before
   235      sending any additional keys. This is useful if you have to generally wait
   236      for the UI to update before typing more.
   237  
   238  In addition to the special keys, each command to type is treated as a
   239  [configuration template](/docs/templates/configuration-templates.html). The
   240  available variables are:
   241  
   242  -   `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server
   243      that is started serving the directory specified by the `http_directory`
   244      configuration parameter. If `http_directory` isn't specified, these will be
   245      blank!
   246  
   247  Example boot command. This is actually a working boot command used to start an
   248  Ubuntu 12.04 installer:
   249  
   250  ``` {.text}
   251  [
   252    "<esc><esc><enter><wait>",
   253    "/install/vmlinuz noapic ",
   254    "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
   255    "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
   256    "hostname={{ .Name }} ",
   257    "fb=false debconf/frontend=noninteractive ",
   258    "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
   259    "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
   260    "initrd=/install/initrd.gz -- <enter>"
   261  ]
   262  ```