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