github.com/ratanraj/packer@v1.3.2/website/source/docs/builders/vmware-vmx.html.md.erb (about)

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