github.com/jerryclinesmith/packer@v0.3.7/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", "sha256", or "sha512" 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 * `disk_type_id` (string) - The type of VMware virtual disk to create. 84 The default is "1", which corresponds to a growable virtual disk split in 85 2GB files. This option is for advanced usage, modify only if you 86 know what you're doing. For more information, please consult the 87 [Virtual Disk Manager User's Guide](http://www.vmware.com/pdf/VirtualDiskManager.pdf). 88 89 * `floppy_files` (array of strings) - A list of files to put onto a floppy 90 disk that is attached when the VM is booted for the first time. This is 91 most useful for unattended Windows installs, which look for an 92 `Autounattend.xml` file on removable media. By default no floppy will 93 be attached. The files listed in this configuration will all be put 94 into the root directory of the floppy disk; sub-directories are not supported. 95 96 * `guest_os_type` (string) - The guest OS type being installed. This will be 97 set in the VMware VMX. By default this is "other". By specifying a more specific 98 OS type, VMware may perform some optimizations or virtual hardware changes 99 to better support the operating system running in the virtual machine. 100 101 * `headless` (bool) - Packer defaults to building VMware 102 virtual machines by launching a GUI that shows the console of the 103 machine being built. When this value is set to true, the machine will 104 start without a console. For VMware machines, Packer will output VNC 105 connection information in case you need to connect to the console to 106 debug the build process. 107 108 * `http_directory` (string) - Path to a directory to serve using an HTTP 109 server. The files in this directory will be available over HTTP that will 110 be requestable from the virtual machine. This is useful for hosting 111 kickstart files and so on. By default this is "", which means no HTTP 112 server will be started. The address and port of the HTTP server will be 113 available as variables in `boot_command`. This is covered in more detail 114 below. 115 116 * `http_port_min` and `http_port_max` (int) - These are the minimum and 117 maximum port to use for the HTTP server started to serve the `http_directory`. 118 Because Packer often runs in parallel, Packer will choose a randomly available 119 port in this range to run the HTTP server. If you want to force the HTTP 120 server to be on one port, make this minimum and maximum port the same. 121 By default the values are 8000 and 9000, respectively. 122 123 * `iso_urls` (array of strings) - Multiple URLs for the ISO to download. 124 Packer will try these in order. If anything goes wrong attempting to download 125 or while downloading a single URL, it will move on to the next. All URLs 126 must point to the same file (same checksum). By default this is empty 127 and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be specified. 128 129 * `output_directory` (string) - This is the path to the directory where the 130 resulting virtual machine will be created. This may be relative or absolute. 131 If relative, the path is relative to the working directory when `packer` 132 is executed. This directory must not exist or be empty prior to running the builder. 133 By default this is "output-BUILDNAME" where "BUILDNAME" is the name 134 of the build. 135 136 * `skip_compaction` (bool) - VMware-created disks are defragmented 137 and compacted at the end of the build process using `vmware-vdiskmanager`. 138 In 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 * `shutdown_command` (string) - The command to use to gracefully shut down 143 the machine once all the provisioning is done. By default this is an empty 144 string, which tells Packer to just forcefully shut down the machine. 145 146 * `shutdown_timeout` (string) - The amount of time to wait after executing 147 the `shutdown_command` for the virtual machine to actually shut down. 148 If it doesn't shut down in this time, it is an error. By default, the timeout 149 is "5m", or five minutes. 150 151 * `ssh_key_path` (string) - Path to a private key to use for authenticating 152 with SSH. By default this is not set (key-based auth won't be used). 153 The associated public key is expected to already be configured on the 154 VM being prepared by some other process (kickstart, etc.). 155 156 * `ssh_password` (string) - The password for `ssh_username` to use to 157 authenticate with SSH. By default this is the empty string. 158 159 * `ssh_port` (int) - The port that SSH will listen on within the virtual 160 machine. By default this is 22. 161 162 * `ssh_skip_request_pty` (bool) - If true, a pty will not be requested as 163 part of the SSH connection. By default, this is "false", so a pty 164 _will_ be requested. 165 166 * `ssh_wait_timeout` (string) - The duration to wait for SSH to become 167 available. By default this is "20m", or 20 minutes. Note that this should 168 be quite long since the timer begins as soon as the virtual machine is booted. 169 170 * `tools_upload_flavor` (string) - The flavor of the VMware Tools ISO to 171 upload into the VM. Valid values are "darwin", "linux", and "windows". 172 By default, this is empty, which means VMware tools won't be uploaded. 173 174 * `tools_upload_path` (string) - The path in the VM to upload the VMware 175 tools. This only takes effect if `tools_upload_flavor` is non-empty. 176 This is a [configuration template](/docs/templates/configuration-templates.html) 177 that has a single valid variable: `Flavor`, which will be the value of 178 `tools_upload_flavor`. By default the upload path is set to 179 `{{.Flavor}}.iso`. 180 181 * `vm_name` (string) - This is the name of the VMX file for the new virtual 182 machine, without the file extension. By default this is "packer-BUILDNAME", 183 where "BUILDNAME" is the name of the build. 184 185 * `vmdk_name` (string) - The filename of the virtual disk that'll be created, 186 without the extension. This defaults to "packer". 187 188 * `vmx_data` (object, string keys and string values) - Arbitrary key/values 189 to enter into the virtual machine VMX file. This is for advanced users 190 who want to set properties such as memory, CPU, etc. 191 192 * `vnc_port_min` and `vnc_port_max` (int) - The minimum and maximum port to 193 use for VNC access to the virtual machine. The builder uses VNC to type 194 the initial `boot_command`. Because Packer generally runs in parallel, Packer 195 uses a randomly chosen port in this range that appears available. By default 196 this is 5900 to 6000. The minimum and maximum ports are inclusive. 197 198 * `vmx_template_path` (string) - Path to a 199 [configuration template](/docs/templates/configuration-templates.html) that 200 defines the contents of the virtual machine VMX file for VMware. This is 201 for **advanced users only** as this can render the virtual machine 202 non-functional. See below for more information. For basic VMX modifications, 203 try `vmx_data` first. 204 205 ## Boot Command 206 207 The `boot_command` configuration is very important: it specifies the keys 208 to type when the virtual machine is first booted in order to start the 209 OS installer. This command is typed after `boot_wait`, which gives the 210 virtual machine some time to actually load the ISO. 211 212 As documented above, the `boot_command` is an array of strings. The 213 strings are all typed in sequence. It is an array only to improve readability 214 within the template. 215 216 The boot command is "typed" character for character over a VNC connection 217 to the machine, simulating a human actually typing the keyboard. There are 218 a set of special keys available. If these are in your boot command, they 219 will be replaced by the proper key: 220 221 * `<enter>` and `<return>` - Simulates an actual "enter" or "return" keypress. 222 223 * `<esc>` - Simulates pressing the escape key. 224 225 * `<tab>` - Simulates pressing the tab key. 226 227 * `<wait>` `<wait5>` `<wait10>` - Adds a 1, 5 or 10 second pause before sending any additional keys. This 228 is useful if you have to generally wait for the UI to update before typing more. 229 230 In addition to the special keys, each command to type is treated as a 231 [configuration template](/docs/templates/configuration-templates.html). 232 The available variables are: 233 234 * `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server 235 that is started serving the directory specified by the `http_directory` 236 configuration parameter. If `http_directory` isn't specified, these will 237 be blank! 238 239 Example boot command. This is actually a working boot command used to start 240 an Ubuntu 12.04 installer: 241 242 <pre class="prettyprint"> 243 [ 244 "<esc><esc><enter><wait>", 245 "/install/vmlinuz noapic ", 246 "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", 247 "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ", 248 "hostname={{ .Name }} ", 249 "fb=false debconf/frontend=noninteractive ", 250 "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", 251 "keyboard-configuration/variant=USA console-setup/ask_detect=false ", 252 "initrd=/install/initrd.gz -- <enter>" 253 ] 254 </pre> 255 256 ## VMX Template 257 258 The heart of a VMware machine is the "vmx" file. This contains all the 259 virtual hardware metadata necessary for the VM to function. Packer by default 260 uses a [safe, flexible VMX file](https://github.com/mitchellh/packer/blob/20541a7eda085aa5cf35bfed5069592ca49d106e/builder/vmware/step_create_vmx.go#L84). 261 But for advanced users, this template can be customized. This allows 262 Packer to build virtual machines of effectively any guest operating system 263 type. 264 265 <div class="alert alert-block alert-warn"> 266 <p> 267 <strong>This is an advanced feature.</strong> Modifying the VMX template 268 can easily cause your virtual machine to not boot properly. Please only 269 modify the template if you know what you're doing. 270 </p> 271 </div> 272 273 Within the template, a handful of variables are available so that your 274 template can continue working with the rest of the Packer machinery. Using 275 these variables isn't required, however. 276 277 * `Name` - The name of the virtual machine. 278 * `GuestOS` - The VMware-valid guest OS type. 279 * `DiskName` - The filename (without the suffix) of the main virtual disk. 280 * `ISOPath` - The path to the ISO to use for the OS installation.