Hyper-V VMCX: Fix long lines

This commit is contained in:
DanHam 2018-06-14 16:36:24 +01:00
parent 647aef9855
commit 9f528d6eb7
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 95 additions and 86 deletions

View File

@ -12,20 +12,21 @@ page_title: "Hyper-V Builder (from an vmcx)"
Type: `hyperv-vmcx` Type: `hyperv-vmcx`
The Hyper-V Packer builder is able to use exported virtual machines or clone existing The Hyper-V Packer builder is able to use exported virtual machines or clone
existing
[Hyper-V](https://www.microsoft.com/en-us/server-cloud/solutions/virtualization.aspx) [Hyper-V](https://www.microsoft.com/en-us/server-cloud/solutions/virtualization.aspx)
virtual machines. virtual machines.
The builder imports a virtual machine or clones an existing virtual machine boots it, The builder imports a virtual machine or clones an existing virtual machine
and provisioning software within the OS, then shutting it down. The result of the boots it, and provisioning software within the OS, then shutting it down. The
Hyper-V builder is a directory containing all the files necessary to run the virtual result of the Hyper-V builder is a directory containing all the files
machine portably. necessary to run the virtual machine portably.
## Basic Example ## Basic Example
Here is a basic example. This example is not functional. It will start the Here is a basic example. This example is not functional. It will start the OS
OS installer but then fail because we don't provide the preseed file for installer but then fail because we don't provide the preseed file for Ubuntu
Ubuntu to self-install. Still, the example serves to show the basic configuration: to self-install. Still, the example serves to show the basic configuration:
Import from folder: Import from folder:
@ -57,13 +58,13 @@ provisioner might not be saved.
## Configuration Reference ## Configuration Reference
There are many configuration options available for the Hyper-V builder. There are many configuration options available for the Hyper-V builder. They
They are organized below into two categories: required and optional. Within are organized below into two categories: required and optional. Within each
each category, the available options are alphabetized and described. category, the available options are alphabetized and described.
In addition to the options listed here, a In addition to the options listed here, a
[communicator](/docs/templates/communicator.html) [communicator](/docs/templates/communicator.html) can be configured for this
can be configured for this builder. builder.
### Required for virtual machine import: ### Required for virtual machine import:
@ -83,11 +84,11 @@ can be configured for this builder.
machine is cloned. machine is cloned.
- `boot_command` (array of strings) - This is an array of commands to type - `boot_command` (array of strings) - This is an array of commands to type
when the virtual machine is first booted. The goal of these commands should when the virtual machine is first booted. The goal of these commands
be to type just enough to initialize the operating system installer. should be to type just enough to initialize the operating system
Special keys can be typed as well, and are covered in the section below on installer. Special keys can be typed as well, and are covered in the
the boot command. If this is not specified, it is assumed the installer section below on the boot command. If this is not specified, it is assumed
will start itself. the installer will start itself.
- `boot_wait` (string) - The time to wait after booting the initial virtual - `boot_wait` (string) - The time to wait after booting the initial virtual
machine before typing the `boot_command`. The value of this should be machine before typing the `boot_command`. The value of this should be
@ -98,39 +99,42 @@ can be configured for this builder.
- `cpu` (number) - The number of cpus the virtual machine should use. If - `cpu` (number) - The number of cpus the virtual machine should use. If
this isn't specified, the default is 1 cpu. this isn't specified, the default is 1 cpu.
- `enable_dynamic_memory` (boolean) - If true enable dynamic memory for virtual - `enable_dynamic_memory` (boolean) - If true enable dynamic memory for
machine. This defaults to false. virtual machine. This defaults to false.
- `enable_mac_spoofing` (boolean) - If true enable mac spoofing for virtual - `enable_mac_spoofing` (boolean) - If true enable mac spoofing for virtual
machine. This defaults to false. machine. This defaults to false.
- `enable_secure_boot` (boolean) - If true enable secure boot for virtual machine. This defaults to false. - `enable_secure_boot` (boolean) - If true enable secure boot for virtual
machine. This defaults to false.
- `secure_boot_template` (string) - The secure boot template to be configured. Valid values are "MicrosoftWindows" (Windows) or - `secure_boot_template` (string) - The secure boot template to be
"MicrosoftUEFICertificateAuthority" (Linux). This only takes effect if enable_secure_boot is set to "true". This defaults to "MicrosoftWindows". configured. Valid values are "MicrosoftWindows" (Windows) or
"MicrosoftUEFICertificateAuthority" (Linux). This only takes effect if
enable_secure_boot is set to "true". This defaults to "MicrosoftWindows".
- `enable_virtualization_extensions` (boolean) - If true enable virtualization - `enable_virtualization_extensions` (boolean) - If true enable
extensions for virtual machine. This defaults to false. For nested virtualization extensions for virtual machine. This defaults to false. For
virtualization you need to enable mac spoofing, disable dynamic memory and nested virtualization you need to enable mac spoofing, disable dynamic
have at least 4GB of RAM for virtual machine. memory and have at least 4GB of RAM for virtual machine.
- `floppy_files` (array of strings) - A list of files to place onto a floppy - `floppy_files` (array of strings) - A list of files to place onto a floppy
disk that is attached when the VM is booted. This is most useful for disk that is attached when the VM is booted. This is most useful for
unattended Windows installs, which look for an `Autounattend.xml` file on unattended Windows installs, which look for an `Autounattend.xml` file on
removable media. By default, no floppy will be attached. All files listed removable media. By default, no floppy will be attached. All files listed
in this setting get placed into the root directory of the floppy and the in this setting get placed into the root directory of the floppy and the
floppy is attached as the first floppy device. Currently, no support exists floppy is attached as the first floppy device. Currently, no support
for creating sub-directories on the floppy. Wildcard characters (*, ?, and exists for creating sub-directories on the floppy. Wildcard characters (*,
[]) are allowed. Directory names are also allowed, which will add all the ?, and []) are allowed. Directory names are also allowed, which will add
files found in the directory to the floppy. all the files found in the directory to the floppy.
- `floppy_dirs` (array of strings) - A list of directories to place onto the - `floppy_dirs` (array of strings) - A list of directories to place onto the
floppy disk recursively. This is similar to the `floppy_files` option floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed. contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are
The maximum summary size of all files in the listed directories are the allowed. The maximum summary size of all files in the listed directories
same as in `floppy_files`. are the same as in `floppy_files`.
- `guest_additions_mode` (string) - How should guest additions be installed. - `guest_additions_mode` (string) - How should guest additions be installed.
If value `attach` then attach iso image with by specified by If value `attach` then attach iso image with by specified by
@ -140,9 +144,9 @@ can be configured for this builder.
additions. additions.
- `headless` (boolean) - Packer defaults to building Hyper-V virtual - `headless` (boolean) - Packer defaults to building Hyper-V virtual
machines by launching a GUI that shows the console of the machine machines by launching a GUI that shows the console of the machine being
being built. When this value is set to true, the machine will start without built. When this value is set to true, the machine will start without a
a console. console.
- `http_directory` (string) - Path to a directory to serve using an HTTP - `http_directory` (string) - Path to a directory to serve using an HTTP
server. The files in this directory will be available over HTTP that will server. The files in this directory will be available over HTTP that will
@ -154,10 +158,11 @@ can be configured for this builder.
- `http_port_min` and `http_port_max` (number) - These are the minimum and - `http_port_min` and `http_port_max` (number) - These are the minimum and
maximum port to use for the HTTP server started to serve the maximum port to use for the HTTP server started to serve the
`http_directory`. Because Packer often runs in parallel, Packer will choose `http_directory`. Because Packer often runs in parallel, Packer will
a randomly available port in this range to run the HTTP server. If you want choose a randomly available port in this range to run the HTTP server. If
to force the HTTP server to be on one port, make this minimum and maximum you want to force the HTTP server to be on one port, make this minimum and
port the same. By default the values are 8000 and 9000, respectively. maximum port the same. By default the values are 8000 and 9000,
respectively.
- `iso_checksum` (string) - The checksum for the OS ISO file. Because ISO - `iso_checksum` (string) - The checksum for the OS ISO file. Because ISO
files are so large, this is required and Packer will verify it prior to files are so large, this is required and Packer will verify it prior to
@ -171,16 +176,16 @@ can be configured for this builder.
from time to time. from time to time.
- `iso_url` (string) - A URL to the ISO or VHD containing the installation - `iso_url` (string) - A URL to the ISO or VHD containing the installation
image. This URL can be either an HTTP URL or a file URL (or path to image. This URL can be either an HTTP URL or a file URL (or path to a
a file). If this is an HTTP URL, Packer will download iso and cache it file). If this is an HTTP URL, Packer will download iso and cache it
between runs. between runs.
- `iso_urls` (array of strings) - Multiple URLs for the ISO or VHD to - `iso_urls` (array of strings) - Multiple URLs for the ISO or VHD to
download. Packer will try these in order. If anything goes wrong attempting download. Packer will try these in order. If anything goes wrong
to download or while downloading a single URL, it will move on to the next. attempting to download or while downloading a single URL, it will move on
All URLs must point to the same file (same checksum). By default this is to the next. All URLs must point to the same file (same checksum). By
empty and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be default this is empty and `iso_url` is used. Only one of `iso_url` or
specified. `iso_urls` can be specified.
- `iso_target_extension` (string) - The extension of the iso file after - `iso_target_extension` (string) - The extension of the iso file after
download. This defaults to "iso". download. This defaults to "iso".
@ -199,23 +204,23 @@ can be configured for this builder.
- `ram_size` (number) - The size, in megabytes, of the ram to create for the - `ram_size` (number) - The size, in megabytes, of the ram to create for the
VM. By default, this is 1 GB. VM. By default, this is 1 GB.
* `secondary_iso_images` (array of strings) - A list of iso paths to attached * `secondary_iso_images` (array of strings) - A list of iso paths to
to a VM when it is booted. This is most useful for unattended Windows attached to a VM when it is booted. This is most useful for unattended
installs, which look for an `Autounattend.xml` file on removable media. By Windows installs, which look for an `Autounattend.xml` file on removable
default, no secondary iso will be attached. media. By default, no secondary iso will be attached.
- `shutdown_command` (string) - The command to use to gracefully shut down - `shutdown_command` (string) - The command to use to gracefully shut down
the machine once all the provisioning is done. By default this is an empty the machine once all the provisioning is done. By default this is an empty
string, which tells Packer to just forcefully shut down the machine unless string, which tells Packer to just forcefully shut down the machine unless
a shutdown command takes place inside script so this may safely be omitted. a shutdown command takes place inside script so this may safely be
If one or more scripts require a reboot it is suggested to leave this blank omitted. If one or more scripts require a reboot it is suggested to leave
since reboots may fail and specify the final shutdown command in your last this blank since reboots may fail and specify the final shutdown command
script. in your last script.
- `shutdown_timeout` (string) - The amount of time to wait after executing - `shutdown_timeout` (string) - The amount of time to wait after executing
the `shutdown_command` for the virtual machine to actually shut down. If it the `shutdown_command` for the virtual machine to actually shut down. If
doesn't shut down in this time, it is an error. By default, the timeout is it doesn't shut down in this time, it is an error. By default, the timeout
"5m", or five minutes. is "5m", or five minutes.
- `skip_compaction` (boolean) - If true skip compacting the hard disk for - `skip_compaction` (boolean) - If true skip compacting the hard disk for
virtual machine when exporting. This defaults to false. virtual machine when exporting. This defaults to false.
@ -226,17 +231,17 @@ can be configured for this builder.
running. running.
- `switch_vlan_id` (string) - This is the vlan of the virtual switch's - `switch_vlan_id` (string) - This is the vlan of the virtual switch's
network card. By default none is set. If none is set then a vlan is not set network card. By default none is set. If none is set then a vlan is not
on the switch's network card. If this value is set it should match the vlan set on the switch's network card. If this value is set it should match the
specified in by `vlan_id`. vlan specified in by `vlan_id`.
- `vlan_id` (string) - This is the vlan of the virtual machine's network card - `vlan_id` (string) - This is the vlan of the virtual machine's network
for the new virtual machine. By default none is set. If none is set then card for the new virtual machine. By default none is set. If none is set
vlans are not set on the virtual machine's network card. then vlans are not set on the virtual machine's network card.
- `mac_address` (string) - This allows a specific MAC address to be used on the - `mac_address` (string) - This allows a specific MAC address to be used on
default virtual network card. The MAC address must be a string with no the default virtual network card. The MAC address must be a string with
delimiters, for example "0000deadbeef". no delimiters, for example "0000deadbeef".
- `vm_name` (string) - This is the name of the virtual machine for the new - `vm_name` (string) - This is the name of the virtual machine for the new
virtual machine, without the file extension. By default this is virtual machine, without the file extension. By default this is
@ -244,22 +249,22 @@ can be configured for this builder.
## Boot Command ## Boot Command
The `boot_command` configuration is very important: it specifies the keys The `boot_command` configuration is very important: it specifies the keys to
to type when the virtual machine is first booted in order to start the type when the virtual machine is first booted in order to start the OS
OS installer. This command is typed after `boot_wait`, which gives the installer. This command is typed after `boot_wait`, which gives the virtual
virtual machine some time to actually load the ISO. machine some time to actually load the ISO.
As documented above, the `boot_command` is an array of strings. The As documented above, the `boot_command` is an array of strings. The strings
strings are all typed in sequence. It is an array only to improve readability are all typed in sequence. It is an array only to improve readability within
within the template. the template.
The boot command is "typed" character for character over the virtual keyboard The boot command is "typed" character for character over the virtual keyboard
to the machine, simulating a human actually typing the keyboard. to the machine, simulating a human actually typing the keyboard.
<%= partial "partials/builders/boot-command" %> <%= partial "partials/builders/boot-command" %>
Example boot command. This is actually a working boot command used to start Example boot command. This is actually a working boot command used to start an
an Ubuntu 12.04 installer: Ubuntu 12.04 installer:
```text ```text
[ [
@ -282,18 +287,22 @@ for the version of Hyper-V that is running.
## Generation 1 vs Generation 2 ## Generation 1 vs Generation 2
Floppy drives are no longer supported by generation 2 machines. This requires you to Floppy drives are no longer supported by generation 2 machines. This requires
take another approach when dealing with preseed or answer files. Two possible options you to take another approach when dealing with preseed or answer files. Two
are using virtual dvd drives or using the built in web server. possible options are using virtual dvd drives or using the built in web
server.
When dealing with Windows you need to enable UEFI drives for generation 2 virtual machines. When dealing with Windows you need to enable UEFI drives for generation 2
virtual machines.
## Creating iso from directory ## Creating iso from directory
Programs like mkisofs can be used to create an iso from a directory. Programs like mkisofs can be used to create an iso from a directory. There is
There is a [windows version of mkisofs](http://opensourcepack.blogspot.co.uk/p/cdrtools.html). a [windows version of
mkisofs](http://opensourcepack.blogspot.co.uk/p/cdrtools.html).
Example powershell script. This is an actually working powershell script used to create a Windows answer iso: Example powershell script. This is an actually working powershell script used
to create a Windows answer iso:
```text ```text
$isoFolder = "answer-iso" $isoFolder = "answer-iso"
@ -855,8 +864,8 @@ Finish proxy after sysprep -->
## Example For Ubuntu Vivid Generation 2 ## Example For Ubuntu Vivid Generation 2
If you are running Windows under virtualization, you may need to create If you are running Windows under virtualization, you may need to create a
a virtual switch with an `External` connection type. virtual switch with an `External` connection type.
### Packer config: ### Packer config: