github.com/homburg/packer@v0.6.1-0.20140528012651-1dcaf1716848/website/source/docs/builders/parallels-iso.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Parallels Builder (from an ISO)" 4 --- 5 6 # Parallels Builder (from an ISO) 7 8 Type: `parallels-iso` 9 10 The Parallels builder is able to create 11 [Parallels Desktop for Mac](http://www.parallels.com/products/desktop/) virtual 12 machines and export them in the PVM format, starting from an 13 ISO image. 14 15 The builder builds a virtual machine by creating a new virtual machine 16 from scratch, booting it, installing an OS, provisioning software within 17 the OS, then shutting it down. The result of the Parallels builder is a directory 18 containing all the files necessary to run the virtual machine portably. 19 20 ## Basic Example 21 22 Here is a basic example. This example is not functional. It will start the 23 OS installer but then fail because we don't provide the preseed file for 24 Ubuntu to self-install. Still, the example serves to show the basic configuration: 25 26 <pre class="prettyprint"> 27 { 28 "type": "parallels-iso", 29 "guest_os_type": "Ubuntu_64", 30 "iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.3-server-amd64.iso", 31 "iso_checksum": "2cbe868812a871242cdcdd8f2fd6feb9", 32 "iso_checksum_type": "md5", 33 "ssh_username": "packer", 34 "ssh_password": "packer", 35 "ssh_wait_timeout": "30s", 36 "shutdown_command": "echo 'packer' | sudo -S shutdown -P now" 37 } 38 </pre> 39 40 It is important to add a `shutdown_command`. By default Packer halts the 41 virtual machine and the file system may not be sync'd. Thus, changes made in a 42 provisioner might not be saved. 43 44 ## Configuration Reference 45 46 There are many configuration options available for the Parallels 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 first 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, in megabytes, of the hard disk to create 87 for the VM. By default, this is 40000 (about 40 GB). 88 89 * `floppy_files` (array of strings) - A list of files to place onto a floppy 90 disk that is attached when the VM is booted. This is most useful 91 for unattended Windows installs, which look for an `Autounattend.xml` file 92 on removable media. By default, no floppy will be attached. All files 93 listed in this setting get placed into the root directory of the floppy 94 and the floppy is attached as the first floppy device. Currently, no 95 support exists for creating sub-directories on the floppy. Wildcard 96 characters (*, ?, and []) are allowed. Directory names are also allowed, 97 which will add all the files found in the directory to the floppy. 98 99 * `guest_os_distribution` (string) - The guest OS distribution being 100 installed. By default this is "other", but you can get dramatic 101 performance improvements by setting this to the proper value. To 102 view all available values for this run `prlctl create x --distribution list`. 103 Setting the correct value hints to Parallels how to optimize the virtual 104 hardware to work best with that operating system. 105 106 * `guest_os_type` (string) - The guest OS type being installed. By default 107 this is "other", but you can get _dramatic_ performance improvements by 108 setting this to the proper value. To view all available values for this 109 run `prlctl create x --ostype list`. Setting the correct value hints to 110 Parallels Desktop how to optimize the virtual hardware to work best with 111 that operating system. 112 113 * `hard_drive_interface` (string) - The type of controller that the 114 hard drives are attached to, defaults to "sata". Valid options are 115 "sata", "ide", and "scsi". 116 117 * `host_interfaces` (array of strings) - A list of which interfaces on the 118 host should be searched for a IP address. The first IP address found on 119 one of these will be used as `{{ .HTTPIP }}` in the `boot_command`. 120 Defaults to ["en0", "en1", "en2", "en3", "en4", "en5", "en6", "en7", "en8", 121 "en9", "ppp0", "ppp1", "ppp2"]. 122 123 * `http_directory` (string) - Path to a directory to serve using an HTTP 124 server. The files in this directory will be available over HTTP that will 125 be requestable from the virtual machine. This is useful for hosting 126 kickstart files and so on. By default this is "", which means no HTTP 127 server will be started. The address and port of the HTTP server will be 128 available as variables in `boot_command`. This is covered in more detail 129 below. 130 131 * `http_port_min` and `http_port_max` (integer) - These are the minimum and 132 maximum port to use for the HTTP server started to serve the `http_directory`. 133 Because Packer often runs in parallel, Packer will choose a randomly available 134 port in this range to run the HTTP server. If you want to force the HTTP 135 server to be on one port, make this minimum and maximum port the same. 136 By default the values are 8000 and 9000, respectively. 137 138 * `iso_urls` (array of strings) - Multiple URLs for the ISO to download. 139 Packer will try these in order. If anything goes wrong attempting to download 140 or while downloading a single URL, it will move on to the next. All URLs 141 must point to the same file (same checksum). By default this is empty 142 and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be specified. 143 144 * `output_directory` (string) - This is the path to the directory where the 145 resulting virtual machine will be created. This may be relative or absolute. 146 If relative, the path is relative to the working directory when `packer` 147 is executed. This directory must not exist or be empty prior to running the builder. 148 By default this is "output-BUILDNAME" where "BUILDNAME" is the name 149 of the build. 150 151 * `parallels_tools_guest_path` (string) - The path on the guest virtual machine 152 where the Parallels tools ISO will be uploaded. By default this is 153 "prl-tools.iso" which should upload into the login directory of the user. 154 This is a configuration template where the `Version` variable is replaced 155 with the prlctl version. 156 157 * `parallels_tools_host_path` (string) - The path to the Parallels Tools ISO to 158 upload. By default the Parallels builder will use the "other" OS tools ISO from 159 the Parallels installation: 160 "/Applications/Parallels Desktop.app/Contents/Resources/Tools/prl-tools-other.iso" 161 162 * `parallels_tools_mode` (string) - The method by which Parallels tools are 163 made available to the guest for installation. Valid options are "upload", 164 "attach", or "disable". The functions of each of these should be 165 self-explanatory. The default value is "upload". 166 167 * `prlctl` (array of array of strings) - Custom `prlctl` commands to execute in 168 order to further customize the virtual machine being created. The value of 169 this is an array of commands to execute. The commands are executed in the order 170 defined in the template. For each command, the command is defined itself as an 171 array of strings, where each string represents a single argument on the 172 command-line to `prlctl` (but excluding `prlctl` itself). Each arg is treated 173 as a [configuration template](/docs/templates/configuration-templates.html), 174 where the `Name` variable is replaced with the VM name. More details on how 175 to use `prlctl` are below. 176 177 * `prlctl_version_file` (string) - The path within the virtual machine to upload 178 a file that contains the `prlctl` version that was used to create the machine. 179 This information can be useful for provisioning. By default this is 180 ".prlctl_version", which will generally upload it into the home directory. 181 182 * `shutdown_command` (string) - The command to use to gracefully shut down 183 the machine once all the provisioning is done. By default this is an empty 184 string, which tells Packer to just forcefully shut down the machine. 185 186 * `shutdown_timeout` (string) - The amount of time to wait after executing 187 the `shutdown_command` for the virtual machine to actually shut down. 188 If it doesn't shut down in this time, it is an error. By default, the timeout 189 is "5m", or five minutes. 190 191 * `ssh_key_path` (string) - Path to a private key to use for authenticating 192 with SSH. By default this is not set (key-based auth won't be used). 193 The associated public key is expected to already be configured on the 194 VM being prepared by some other process (kickstart, etc.). 195 196 * `ssh_password` (string) - The password for `ssh_username` to use to 197 authenticate with SSH. By default this is the empty string. 198 199 * `ssh_port` (integer) - The port that SSH will be listening on in the guest 200 virtual machine. By default this is 22. 201 202 * `ssh_wait_timeout` (string) - The duration to wait for SSH to become 203 available. By default this is "20m", or 20 minutes. Note that this should 204 be quite long since the timer begins as soon as the virtual machine is booted. 205 206 * `vm_name` (string) - This is the name of the PVM directory for the new 207 virtual machine, without the file extension. By default this is 208 "packer-BUILDNAME", where "BUILDNAME" is the name of the build. 209 210 ## Boot Command 211 212 The `boot_command` configuration is very important: it specifies the keys 213 to type when the virtual machine is first booted in order to start the 214 OS installer. This command is typed after `boot_wait`, which gives the 215 virtual machine some time to actually load the ISO. 216 217 As documented above, the `boot_command` is an array of strings. The 218 strings are all typed in sequence. It is an array only to improve readability 219 within the template. 220 221 The boot command is "typed" character for character using the `prltype` (part 222 of prl-utils, see [Parallels Builder](/docs/builders/parallels.html)) 223 command connected to the machine, simulating a human actually typing the 224 keyboard. There are a set of special keys available. If these are in your 225 boot command, they will be replaced by the proper key: 226 227 * `<enter>` and `<return>` - Simulates an actual "enter" or "return" keypress. 228 229 * `<esc>` - Simulates pressing the escape key. 230 231 * `<tab>` - Simulates pressing the tab key. 232 233 * `<wait>` `<wait5>` `<wait10>` - Adds a 1, 5 or 10 second pause before sending 234 any additional keys. This is useful if you have to generally wait for the UI 235 to update before typing more. 236 237 In addition to the special keys, each command to type is treated as a 238 [configuration template](/docs/templates/configuration-templates.html). 239 The available variables are: 240 241 * `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server 242 that is started serving the directory specified by the `http_directory` 243 configuration parameter. If `http_directory` isn't specified, these will 244 be blank! 245 246 Example boot command. This is actually a working boot command used to start 247 an Ubuntu 12.04 installer: 248 249 <pre class="prettyprint"> 250 [ 251 "<esc><esc><enter><wait>", 252 "/install/vmlinuz noapic ", 253 "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", 254 "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ", 255 "hostname={{ .Name }} ", 256 "fb=false debconf/frontend=noninteractive ", 257 "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", 258 "keyboard-configuration/variant=USA console-setup/ask_detect=false ", 259 "initrd=/install/initrd.gz -- <enter>" 260 ] 261 </pre> 262 263 ## Parallels Tools 264 After the virtual machine is up and the operating system is installed, Packer 265 uploads the Parallels Tools into the virtual machine. The path where they are 266 uploaded is controllable by `parallels_tools_path`, and defaults to 267 "prl-tools.iso". Without an absolute path, it is uploaded to the home directory 268 of the SSH user. Parallels Tools ISO's can be found in: 269 "/Applications/Parallels Desktop.app/Contents/Resources/Tools/" 270 271 ## prlctl Commands 272 In order to perform extra customization of the virtual machine, a template can 273 define extra calls to `prlctl` to perform. 274 [prlctl](http://download.parallels.com/desktop/v4/wl/docs/en/Parallels_Command_Line_Reference_Guide/) 275 is the command-line interface to Parallels. It can be used to do things such as 276 set RAM, CPUs, etc. 277 278 Extra `prlctl` commands are defined in the template in the `prlctl` section. 279 An example is shown below that sets the memory and number of CPUs within the 280 virtual machine: 281 282 <pre class="prettyprint"> 283 { 284 "prlctl": [ 285 ["set", "{{.Name}}", "--memsize", "1024"], 286 ["set", "{{.Name}}", "--cpus", "2"] 287 ] 288 } 289 </pre> 290 291 The value of `prlctl` is an array of commands to execute. These commands are 292 executed in the order defined. So in the above example, the memory will be set 293 followed by the CPUs. 294 295 Each command itself is an array of strings, where each string is an argument to 296 `prlctl`. Each argument is treated as a 297 [configuration template](/docs/templates/configuration-templates.html). The only 298 available variable is `Name` which is replaced with the unique name of the VM, 299 which is required for many `prlctl` calls.