github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/website/source/docs/builders/vmware-iso.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "VMware Builder from ISO" 4 --- 5 6 # VMware Builder (from ISO) 7 8 Type: `vmware-iso` 9 10 This VMware builder is able to create VMware virtual machines from an 11 ISO file as a source. It currently 12 supports building virtual machines on hosts running 13 [VMware Fusion](http://www.vmware.com/products/fusion/overview.html) for OS X, 14 [VMware Workstation](http://www.vmware.com/products/workstation/overview.html) 15 for Linux and Windows, and 16 [VMware Player](http://www.vmware.com/products/player/) on Linux. It can 17 also build machines directly on 18 [VMware vSphere Hypervisor](http://www.vmware.com/products/vsphere-hypervisor/) 19 using SSH as opposed to the vSphere API. 20 21 The builder builds a virtual machine by creating a new virtual machine 22 from scratch, booting it, installing an OS, provisioning software within 23 the OS, then shutting it down. The result of the VMware builder is a directory 24 containing all the files necessary to run the virtual machine. 25 26 ## Basic Example 27 28 Here is a basic example. This example is not functional. It will start the 29 OS installer but then fail because we don't provide the preseed file for 30 Ubuntu to self-install. Still, the example serves to show the basic configuration: 31 32 <pre class="prettyprint"> 33 { 34 "type": "vmware-iso", 35 "iso_url": "http://old-releases.ubuntu.com/releases/precise/ubuntu-12.04.2-server-amd64.iso", 36 "iso_checksum": "af5f788aee1b32c4b2634734309cc9e9", 37 "iso_checksum_type": "md5", 38 "ssh_username": "packer", 39 "ssh_wait_timeout": "30s", 40 "shutdown_command": "shutdown -P now" 41 } 42 </pre> 43 44 ## Configuration Reference 45 46 There are many configuration options available for the VMware builder. 47 They are organized below into two categories: required and optional. Within 48 each category, the available options are alphabetized and described. 49 50 ### Required: 51 52 * `iso_checksum` (string) - The checksum for the OS ISO file. Because ISO 53 files are so large, this is required and Packer will verify it prior 54 to booting a virtual machine with the ISO attached. The type of the 55 checksum is specified with `iso_checksum_type`, documented below. 56 57 * `iso_checksum_type` (string) - The type of the checksum specified in 58 `iso_checksum`. Valid values are "none", "md5", "sha1", "sha256", or 59 "sha512" currently. While "none" will skip checksumming, this is not 60 recommended since ISO files are generally large and corruption does happen 61 from time to time. 62 63 * `iso_url` (string) - A URL to the ISO containing the installation image. 64 This URL can be either an HTTP URL or a file URL (or path to a file). 65 If this is an HTTP URL, Packer will download it and cache it between 66 runs. 67 68 * `ssh_username` (string) - The username to use to SSH into the machine 69 once the OS is installed. 70 71 ### Optional: 72 73 * `boot_command` (array of strings) - This is an array of commands to type 74 when the virtual machine is firsted booted. The goal of these commands should 75 be to type just enough to initialize the operating system installer. Special 76 keys can be typed as well, and are covered in the section below on the boot 77 command. If this is not specified, it is assumed the installer will start 78 itself. 79 80 * `boot_wait` (string) - The time to wait after booting the initial virtual 81 machine before typing the `boot_command`. The value of this should be 82 a duration. Examples are "5s" and "1m30s" which will cause Packer to wait 83 five seconds and one minute 30 seconds, respectively. If this isn't specified, 84 the default is 10 seconds. 85 86 * `disk_size` (integer) - The size of the hard disk for the VM in megabytes. 87 The builder uses expandable, not fixed-size virtual hard disks, so the 88 actual file representing the disk will not use the full size unless it is full. 89 By default this is set to 40,000 (about 40 GB). 90 91 * `disk_type_id` (string) - The type of VMware virtual disk to create. 92 The default is "1", which corresponds to a growable virtual disk split in 93 2GB files. This option is for advanced usage, modify only if you 94 know what you're doing. For more information, please consult the 95 [Virtual Disk Manager User's Guide](http://www.vmware.com/pdf/VirtualDiskManager.pdf) 96 for desktop VMware clients. For ESXi, refer to the proper ESXi documentation. 97 98 * `floppy_files` (array of strings) - A list of files to place onto a floppy 99 disk that is attached when the VM is booted. This is most useful 100 for unattended Windows installs, which look for an `Autounattend.xml` file 101 on removable media. By default, no floppy will be attached. All files 102 listed in this setting get placed into the root directory of the floppy 103 and the floppy is attached as the first floppy device. Currently, no 104 support exists for creating sub-directories on the floppy. Wildcard 105 characters (*, ?, and []) are allowed. Directory names are also allowed, 106 which will add all the files found in the directory to the floppy. 107 108 * `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this 109 is "/Applications/VMware Fusion.app" but this setting allows you to 110 customize this. 111 112 * `guest_os_type` (string) - The guest OS type being installed. This will be 113 set in the VMware VMX. By default this is "other". By specifying a more specific 114 OS type, VMware may perform some optimizations or virtual hardware changes 115 to better support the operating system running in the virtual machine. 116 117 * `headless` (boolean) - Packer defaults to building VMware 118 virtual machines by launching a GUI that shows the console of the 119 machine being built. When this value is set to true, the machine will 120 start without a console. For VMware machines, Packer will output VNC 121 connection information in case you need to connect to the console to 122 debug the build process. 123 124 * `http_directory` (string) - Path to a directory to serve using an HTTP 125 server. The files in this directory will be available over HTTP that will 126 be requestable from the virtual machine. This is useful for hosting 127 kickstart files and so on. By default this is "", which means no HTTP 128 server will be started. The address and port of the HTTP server will be 129 available as variables in `boot_command`. This is covered in more detail 130 below. 131 132 * `http_port_min` and `http_port_max` (integer) - These are the minimum and 133 maximum port to use for the HTTP server started to serve the `http_directory`. 134 Because Packer often runs in parallel, Packer will choose a randomly available 135 port in this range to run the HTTP server. If you want to force the HTTP 136 server to be on one port, make this minimum and maximum port the same. 137 By default the values are 8000 and 9000, respectively. 138 139 * `iso_urls` (array of strings) - Multiple URLs for the ISO to download. 140 Packer will try these in order. If anything goes wrong attempting to download 141 or while downloading a single URL, it will move on to the next. All URLs 142 must point to the same file (same checksum). By default this is empty 143 and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be specified. 144 145 * `output_directory` (string) - This is the path to the directory where the 146 resulting virtual machine will be created. This may be relative or absolute. 147 If relative, the path is relative to the working directory when `packer` 148 is executed. This directory must not exist or be empty prior to running the builder. 149 By default this is "output-BUILDNAME" where "BUILDNAME" is the name 150 of the build. 151 152 * `remote_datastore` (string) - The path to the datastore where the resulting 153 VM will be stored when it is built on the remote machine. By default this 154 is "datastore1". This only has an effect if `remote_type` is enabled. 155 156 * `remote_host` (string) - The host of the remote machine used for access. 157 This is only required if `remote_type` is enabled. 158 159 * `remote_password` (string) - The SSH password for the user used to 160 access the remote machine. By default this is empty. This only has an 161 effect if `remote_type` is enabled. 162 163 * `remote_type` (string) - The type of remote machine that will be used to 164 build this VM rather than a local desktop product. The only value accepted 165 for this currently is "esx5". If this is not set, a desktop product will be 166 used. By default, this is not set. 167 168 * `remote_username` (string) - The username for the SSH user that will access 169 the remote machine. This is required if `remote_type` is enabled. 170 171 * `shutdown_command` (string) - The command to use to gracefully shut down 172 the machine once all the provisioning is done. By default this is an empty 173 string, which tells Packer to just forcefully shut down the machine. 174 175 * `shutdown_timeout` (string) - The amount of time to wait after executing 176 the `shutdown_command` for the virtual machine to actually shut down. 177 If it doesn't shut down in this time, it is an error. By default, the timeout 178 is "5m", or five minutes. 179 180 * `skip_compaction` (boolean) - VMware-created disks are defragmented 181 and compacted at the end of the build process using `vmware-vdiskmanager`. 182 In certain rare cases, this might actually end up making the resulting disks 183 slightly larger. If you find this to be the case, you can disable compaction 184 using this configuration value. 185 186 * `ssh_host` (string) - Hostname or IP address of the host. By default, DHCP 187 is used to connect to the host and this field is not used. 188 189 * `ssh_key_path` (string) - Path to a private key to use for authenticating 190 with SSH. By default this is not set (key-based auth won't be used). 191 The associated public key is expected to already be configured on the 192 VM being prepared by some other process (kickstart, etc.). 193 194 * `ssh_password` (string) - The password for `ssh_username` to use to 195 authenticate with SSH. By default this is the empty string. 196 197 * `ssh_port` (integer) - The port that SSH will listen on within the virtual 198 machine. By default this is 22. 199 200 * `ssh_skip_request_pty` (boolean) - If true, a pty will not be requested as 201 part of the SSH connection. By default, this is "false", so a pty 202 _will_ be requested. 203 204 * `ssh_wait_timeout` (string) - The duration to wait for SSH to become 205 available. By default this is "20m", or 20 minutes. Note that this should 206 be quite long since the timer begins as soon as the virtual machine is booted. 207 208 * `tools_upload_flavor` (string) - The flavor of the VMware Tools ISO to 209 upload into the VM. Valid values are "darwin", "linux", and "windows". 210 By default, this is empty, which means VMware tools won't be uploaded. 211 212 * `tools_upload_path` (string) - The path in the VM to upload the VMware 213 tools. This only takes effect if `tools_upload_flavor` is non-empty. 214 This is a [configuration template](/docs/templates/configuration-templates.html) 215 that has a single valid variable: `Flavor`, which will be the value of 216 `tools_upload_flavor`. By default the upload path is set to 217 `{{.Flavor}}.iso`. 218 219 * `vm_name` (string) - This is the name of the VMX file for the new virtual 220 machine, without the file extension. By default this is "packer-BUILDNAME", 221 where "BUILDNAME" is the name of the build. 222 223 * `vmdk_name` (string) - The filename of the virtual disk that'll be created, 224 without the extension. This defaults to "packer". 225 226 * `vmx_data` (object of key/value strings) - Arbitrary key/values 227 to enter into the virtual machine VMX file. This is for advanced users 228 who want to set properties such as memory, CPU, etc. 229 230 * `vmx_data_post` (object of key/value strings) - Identical to `vmx_data`, 231 except that it is run after the virtual machine is shutdown, and before the 232 virtual machine is exported. 233 234 * `vmx_template_path` (string) - Path to a 235 [configuration template](/docs/templates/configuration-templates.html) that 236 defines the contents of the virtual machine VMX file for VMware. This is 237 for **advanced users only** as this can render the virtual machine 238 non-functional. See below for more information. For basic VMX modifications, 239 try `vmx_data` first. 240 241 * `vnc_port_min` and `vnc_port_max` (integer) - The minimum and maximum port to 242 use for VNC access to the virtual machine. The builder uses VNC to type 243 the initial `boot_command`. Because Packer generally runs in parallel, Packer 244 uses a randomly chosen port in this range that appears available. By default 245 this is 5900 to 6000. The minimum and maximum ports are inclusive. 246 247 ## Boot Command 248 249 The `boot_command` configuration is very important: it specifies the keys 250 to type when the virtual machine is first booted in order to start the 251 OS installer. This command is typed after `boot_wait`, which gives the 252 virtual machine some time to actually load the ISO. 253 254 As documented above, the `boot_command` is an array of strings. The 255 strings are all typed in sequence. It is an array only to improve readability 256 within the template. 257 258 The boot command is "typed" character for character over a VNC connection 259 to the machine, simulating a human actually typing the keyboard. There are 260 a set of special keys available. If these are in your boot command, they 261 will be replaced by the proper key: 262 263 * `<enter>` and `<return>` - Simulates an actual "enter" or "return" keypress. 264 265 * `<esc>` - Simulates pressing the escape key. 266 267 * `<tab>` - Simulates pressing the tab key. 268 269 * `<wait>` `<wait5>` `<wait10>` - Adds a 1, 5 or 10 second pause before sending any additional keys. This 270 is useful if you have to generally wait for the UI to update before typing more. 271 272 In addition to the special keys, each command to type is treated as a 273 [configuration template](/docs/templates/configuration-templates.html). 274 The available variables are: 275 276 * `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server 277 that is started serving the directory specified by the `http_directory` 278 configuration parameter. If `http_directory` isn't specified, these will 279 be blank! 280 281 Example boot command. This is actually a working boot command used to start 282 an Ubuntu 12.04 installer: 283 284 <pre class="prettyprint"> 285 [ 286 "<esc><esc><enter><wait>", 287 "/install/vmlinuz noapic ", 288 "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", 289 "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ", 290 "hostname={{ .Name }} ", 291 "fb=false debconf/frontend=noninteractive ", 292 "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", 293 "keyboard-configuration/variant=USA console-setup/ask_detect=false ", 294 "initrd=/install/initrd.gz -- <enter>" 295 ] 296 </pre> 297 298 ## VMX Template 299 300 The heart of a VMware machine is the "vmx" file. This contains all the 301 virtual hardware metadata necessary for the VM to function. Packer by default 302 uses a [safe, flexible VMX file](https://github.com/mitchellh/packer/blob/20541a7eda085aa5cf35bfed5069592ca49d106e/builder/vmware/step_create_vmx.go#L84). 303 But for advanced users, this template can be customized. This allows 304 Packer to build virtual machines of effectively any guest operating system 305 type. 306 307 <div class="alert alert-block alert-warn"> 308 <p> 309 <strong>This is an advanced feature.</strong> Modifying the VMX template 310 can easily cause your virtual machine to not boot properly. Please only 311 modify the template if you know what you're doing. 312 </p> 313 </div> 314 315 Within the template, a handful of variables are available so that your 316 template can continue working with the rest of the Packer machinery. Using 317 these variables isn't required, however. 318 319 * `Name` - The name of the virtual machine. 320 * `GuestOS` - The VMware-valid guest OS type. 321 * `DiskName` - The filename (without the suffix) of the main virtual disk. 322 * `ISOPath` - The path to the ISO to use for the OS installation. 323 324 ## Building on a Remote vSphere Hypervisor 325 326 In addition to using the desktop products of VMware locally to build 327 virtual machines, Packer can use a remote VMware Hypervisor to build 328 the virtual machine. 329 330 <div class="alert alert-block alert-info"> 331 Note: Packer supports ESXi 5.1 and above. 332 </div> 333 334 Before using a remote vSphere Hypervisor, you need to enable GuestIPHack by running the following command: 335 336 ``` 337 esxcli system settings advanced set -o /Net/GuestIPHack -i 1 338 ``` 339 340 When using a remote VMware Hypervisor, the builder still downloads the 341 ISO and various files locally, and uploads these to the remote machine. 342 Packer currently uses SSH to communicate to the ESXi machine rather than 343 the vSphere API. At some point, the vSphere API may be used. 344 345 Packer also requires VNC to issue boot commands during a build, 346 which may be disabled on some remote VMware Hypervisors. Please consult 347 the appropriate documentation on how to update VMware Hypervisor's firewall 348 to allow these connections. 349 350 To use a remote VMware vSphere Hypervisor to build your virtual machine, 351 fill in the required `remote_*` configurations: 352 353 * `remote_type` - This must be set to "esx5". 354 355 * `remote_host` - The host of the remote machine. 356 357 Additionally, there are some optional configurations that you'll likely 358 have to modify as well: 359 360 * `remote_datastore` - The path to the datastore where the VM will be 361 stored on the ESXi machine. 362 363 * `remote_username` - The SSH username used to access the remote machine. 364 365 * `remote_password` - The SSH password for access to the remote machine.