builder/qemu/builder.go: Document from Config file
This commit is contained in:
parent
f4d5842b72
commit
76f50619b1
|
@ -98,29 +98,49 @@ type Config struct {
|
|||
Comm communicator.Config `mapstructure:",squash"`
|
||||
common.FloppyConfig `mapstructure:",squash"`
|
||||
// Use iso from provided url. Qemu must support
|
||||
// curl block device. This defaults to false.
|
||||
// curl block device. This defaults to `false`.
|
||||
ISOSkipCache bool `mapstructure:"iso_skip_cache" required:"false"`
|
||||
// The accelerator type to use when running the VM.
|
||||
// This may be none, kvm, tcg, hax, hvf, whpx, or xen. The appropriate
|
||||
// This may be `none`, `kvm`, `tcg`, `hax`, `hvf`, `whpx`, or `xen`. The appropriate
|
||||
// software must have already been installed on your build machine to use the
|
||||
// accelerator you specified. When no accelerator is specified, Packer will try
|
||||
// to use kvm if it is available but will default to tcg otherwise.
|
||||
// to use `kvm` if it is available but will default to `tcg` otherwise.
|
||||
//
|
||||
// -> The `hax` accelerator has issues attaching CDROM ISOs. This is an
|
||||
// upstream issue which can be tracked
|
||||
// [here](https://github.com/intel/haxm/issues/20).
|
||||
//
|
||||
// -> The `hvf` and `whpx` accelerator are new and experimental as of
|
||||
// [QEMU 2.12.0](https://wiki.qemu.org/ChangeLog/2.12#Host_support).
|
||||
// You may encounter issues unrelated to Packer when using these. You may need to
|
||||
// add [ "-global", "virtio-pci.disable-modern=on" ] to `qemuargs` depending on the
|
||||
// guest operating system.
|
||||
//
|
||||
// -> For `whpx`, note that [Stefan Weil's QEMU for Windows distribution](https://qemu.weilnetz.de/w64/)
|
||||
// does not include WHPX support and users may need to compile or source a
|
||||
// build of QEMU for Windows themselves with WHPX support.
|
||||
Accelerator string `mapstructure:"accelerator" required:"false"`
|
||||
// The number of cpus to use when building the VM.
|
||||
// The default is 1 CPU.
|
||||
// The default is `1` CPU.
|
||||
CpuCount int `mapstructure:"cpus" required:"false"`
|
||||
// The interface to use for the disk. Allowed
|
||||
// values include any of ide, scsi, virtio or virtio-scsi*. Note
|
||||
// also that any boot commands or kickstart type scripts must have proper
|
||||
// adjustments for resulting device names. The Qemu builder uses virtio by
|
||||
// default.
|
||||
// The interface to use for the disk. Allowed values include any of `ide`,
|
||||
// `scsi`, `virtio` or `virtio-scsi`^\*. Note also that any boot commands
|
||||
// or kickstart type scripts must have proper adjustments for resulting
|
||||
// device names. The Qemu builder uses `virtio` by default.
|
||||
//
|
||||
// ^\* Please be aware that use of the `scsi` disk interface has been
|
||||
// disabled by Red Hat due to a bug described
|
||||
// [here](https://bugzilla.redhat.com/show_bug.cgi?id=1019220). If you are
|
||||
// running Qemu on RHEL or a RHEL variant such as CentOS, you *must* choose
|
||||
// one of the other listed interfaces. Using the `scsi` interface under
|
||||
// these circumstances will cause the build to fail.
|
||||
DiskInterface string `mapstructure:"disk_interface" required:"false"`
|
||||
// The size, in megabytes, of the hard disk to create
|
||||
// for the VM. By default, this is 40960 (40 GB).
|
||||
DiskSize uint `mapstructure:"disk_size" required:"false"`
|
||||
// The cache mode to use for disk. Allowed values
|
||||
// include any of writethrough, writeback, none, unsafe
|
||||
// or directsync. By default, this is set to writeback.
|
||||
// The cache mode to use for disk. Allowed values include any of
|
||||
// `writethrough`, `writeback`, `none`, `unsafe` or `directsync`. By
|
||||
// default, this is set to `writeback`.
|
||||
DiskCache string `mapstructure:"disk_cache" required:"false"`
|
||||
// The discard mode to use for disk. Allowed values
|
||||
// include any of unmap or ignore. By default, this is set to ignore.
|
||||
|
@ -137,18 +157,21 @@ type Config struct {
|
|||
// Apply compression to the QCOW2 disk file
|
||||
// using qemu-img convert. Defaults to false.
|
||||
DiskCompression bool `mapstructure:"disk_compression" required:"false"`
|
||||
// Either qcow2 or raw, this specifies the output
|
||||
// format of the virtual machine image. This defaults to qcow2.
|
||||
// Either `qcow2` or `raw`, this specifies the output format of the virtual
|
||||
// machine image. This defaults to `qcow2`.
|
||||
Format string `mapstructure:"format" required:"false"`
|
||||
// Packer defaults to building QEMU virtual machines by
|
||||
// launching a GUI that shows the console of the machine being built. When this
|
||||
// value is set to true, the machine will start without a console.
|
||||
// value is set to `true`, the machine will start without a console.
|
||||
//
|
||||
// You can still see the console if you make a note of the VNC display
|
||||
// number chosen, and then connect using `vncviewer -Shared <host>:<display>`
|
||||
Headless bool `mapstructure:"headless" required:"false"`
|
||||
// Packer defaults to building from an ISO file, this
|
||||
// parameter controls whether the ISO URL supplied is actually a bootable
|
||||
// QEMU image. When this value is set to true, the machine will either clone
|
||||
// the source or use it as a backing file (if use_backing_file is true);
|
||||
// then, it will resize the image according to disk_size and boot it.
|
||||
// Packer defaults to building from an ISO file, this parameter controls
|
||||
// whether the ISO URL supplied is actually a bootable QEMU image. When
|
||||
// this value is set to `true`, the machine will either clone the source or
|
||||
// use it as a backing file (if `use_backing_file` is `true`); then, it
|
||||
// will resize the image according to `disk_size` and boot it.
|
||||
DiskImage bool `mapstructure:"disk_image" required:"false"`
|
||||
// Only applicable when disk_image is true
|
||||
// and format is qcow2, set this option to true to create a new QCOW2
|
||||
|
@ -156,18 +179,18 @@ type Config struct {
|
|||
// will only contain blocks that have changed compared to the backing file, so
|
||||
// enabling this option can significantly reduce disk usage.
|
||||
UseBackingFile bool `mapstructure:"use_backing_file" required:"false"`
|
||||
// The type of machine emulation to use. Run your
|
||||
// qemu binary with the flags -machine help to list available types for
|
||||
// your system. This defaults to pc.
|
||||
// The type of machine emulation to use. Run your qemu binary with the
|
||||
// flags `-machine help` to list available types for your system. This
|
||||
// defaults to `pc`.
|
||||
MachineType string `mapstructure:"machine_type" required:"false"`
|
||||
// The amount of memory to use when building the VM
|
||||
// in megabytes. This defaults to 512 megabytes.
|
||||
MemorySize int `mapstructure:"memory" required:"false"`
|
||||
// The driver to use for the network interface. Allowed
|
||||
// values ne2k_pci, i82551, i82557b, i82559er, rtl8139, e1000,
|
||||
// pcnet, virtio, virtio-net, virtio-net-pci, usb-net, i82559a,
|
||||
// i82559b, i82559c, i82550, i82562, i82557a, i82557c, i82801,
|
||||
// vmxnet3, i82558a or i82558b. The Qemu builder uses virtio-net by
|
||||
// The driver to use for the network interface. Allowed values `ne2k_pci`,
|
||||
// `i82551`, `i82557b`, `i82559er`, `rtl8139`, `e1000`, `pcnet`, `virtio`,
|
||||
// `virtio-net`, `virtio-net-pci`, `usb-net`, `i82559a`, `i82559b`,
|
||||
// `i82559c`, `i82550`, `i82562`, `i82557a`, `i82557c`, `i82801`,
|
||||
// `vmxnet3`, `i82558a` or `i82558b`. The Qemu builder uses `virtio-net` by
|
||||
// default.
|
||||
NetDevice string `mapstructure:"net_device" required:"false"`
|
||||
// This is the path to the directory where the
|
||||
|
@ -177,11 +200,68 @@ type Config struct {
|
|||
// the builder. By default this is output-BUILDNAME where "BUILDNAME" is the
|
||||
// name of the build.
|
||||
OutputDir string `mapstructure:"output_directory" required:"false"`
|
||||
// Allows complete control over the
|
||||
// qemu command line (though not, at this time, qemu-img). Each array of
|
||||
// strings makes up a command line switch that overrides matching default
|
||||
// switch/value pairs. Any value specified as an empty string is ignored. All
|
||||
// values after the switch are concatenated with no separator.
|
||||
// Allows complete control over the qemu command line (though not, at this
|
||||
// time, qemu-img). Each array of strings makes up a command line switch
|
||||
// that overrides matching default switch/value pairs. Any value specified
|
||||
// as an empty string is ignored. All values after the switch are
|
||||
// concatenated with no separator.
|
||||
//
|
||||
// ~> **Warning:** The qemu command line allows extreme flexibility, so
|
||||
// beware of conflicting arguments causing failures of your run. For
|
||||
// instance, using --no-acpi could break the ability to send power signal
|
||||
// type commands (e.g., shutdown -P now) to the virtual machine, thus
|
||||
// preventing proper shutdown. To see the defaults, look in the packer.log
|
||||
// file and search for the qemu-system-x86 command. The arguments are all
|
||||
// printed for review.
|
||||
//
|
||||
// The following shows a sample usage:
|
||||
//
|
||||
// ``` json {
|
||||
// "qemuargs": [
|
||||
// [ "-m", "1024M" ],
|
||||
// [ "--no-acpi", "" ],
|
||||
// [
|
||||
// "-netdev",
|
||||
// "user,id=mynet0,",
|
||||
// "hostfwd=hostip:hostport-guestip:guestport",
|
||||
// ""
|
||||
// ],
|
||||
// [ "-device", "virtio-net,netdev=mynet0" ]
|
||||
// ]
|
||||
// } ```
|
||||
//
|
||||
// would produce the following (not including other defaults supplied by
|
||||
// the builder and not otherwise conflicting with the qemuargs):
|
||||
//
|
||||
// ``` text qemu-system-x86 -m 1024m --no-acpi -netdev
|
||||
// user,id=mynet0,hostfwd=hostip:hostport-guestip:guestport -device
|
||||
// virtio-net,netdev=mynet0" ```
|
||||
//
|
||||
// ~> **Windows Users:** [QEMU for Windows](https://qemu.weilnetz.de/)
|
||||
// builds are available though an environmental variable does need to be
|
||||
// set for QEMU for Windows to redirect stdout to the console instead of
|
||||
// stdout.txt.
|
||||
//
|
||||
// The following shows the environment variable that needs to be set for
|
||||
// Windows QEMU support:
|
||||
//
|
||||
// ``` text setx SDL_STDIO_REDIRECT=0 ```
|
||||
//
|
||||
// You can also use the `SSHHostPort` template variable to produce a packer
|
||||
// template that can be invoked by `make` in parallel:
|
||||
//
|
||||
// ``` json {
|
||||
// "qemuargs": [
|
||||
// [ "-netdev", "user,hostfwd=tcp::{{ .SSHHostPort }}-:22,id=forward"],
|
||||
// [ "-device", "virtio-net,netdev=forward,id=net0"]
|
||||
// ]
|
||||
// } ```
|
||||
//
|
||||
// `make -j 3 my-awesome-packer-templates` spawns 3 packer processes, each
|
||||
// of which will bind to their own SSH port as determined by each process.
|
||||
// This will also work with WinRM, just change the port forward in
|
||||
// `qemuargs` to map to WinRM's default port of `5985` or whatever value
|
||||
// you have the service set to listen on.
|
||||
QemuArgs [][]string `mapstructure:"qemuargs" required:"false"`
|
||||
// The name of the Qemu binary to look for. This
|
||||
// defaults to qemu-system-x86_64, but may need to be changed for
|
||||
|
|
|
@ -77,54 +77,24 @@ Note that you will need to set `"headless": true` if you are running Packer
|
|||
on a Linux server without X11; or if you are connected via ssh to a remote
|
||||
Linux server and have not enabled X11 forwarding (`ssh -X`).
|
||||
|
||||
|
||||
## ISO Configuration Reference
|
||||
|
||||
<%= partial "partials/common/ISOConfig" %>
|
||||
|
||||
### Required:
|
||||
|
||||
- `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
|
||||
booting a virtual machine with the ISO attached. The type of the checksum is
|
||||
specified with `iso_checksum_type`, documented below. At least one of
|
||||
`iso_checksum` and `iso_checksum_url` must be defined. This has precedence
|
||||
over `iso_checksum_url` type.
|
||||
|
||||
- `iso_checksum_type` (string) - The type of the checksum specified in
|
||||
`iso_checksum`. Valid values are `none`, `md5`, `sha1`, `sha256`, or
|
||||
`sha512` currently. While `none` will skip checksumming, this is not
|
||||
recommended since ISO files are generally large and corruption does happen
|
||||
from time to time.
|
||||
|
||||
- `iso_checksum_url` (string) - A URL to a GNU or BSD style checksum file
|
||||
containing a checksum for the OS ISO file. At least one of `iso_checksum`
|
||||
and `iso_checksum_url` must be defined. This will be ignored if
|
||||
`iso_checksum` is non empty.
|
||||
|
||||
- `iso_url` (string) - A URL to the ISO containing the installation image.
|
||||
This URL can be either an HTTP URL or a file URL (or path to a file). If
|
||||
this is an HTTP URL, Packer will download it and cache it between runs.
|
||||
This can also be a URL to an IMG or QCOW2 file, in which case QEMU will
|
||||
boot directly from it. When passing a path to an IMG or QCOW2 file, you
|
||||
should set `disk_image` to `true`.
|
||||
<%= partial "partials/common/ISOConfig-required" %>
|
||||
|
||||
### Optional:
|
||||
|
||||
- `accelerator` (string) - The accelerator type to use when running the VM.
|
||||
This may be `none`, `kvm`, `tcg`, `hax`, `hvf`, `whpx`, or `xen`. The appropriate
|
||||
software must have already been installed on your build machine to use the
|
||||
accelerator you specified. When no accelerator is specified, Packer will try
|
||||
to use `kvm` if it is available but will default to `tcg` otherwise.
|
||||
<%= partial "partials/common/ISOConfig-not-required" %>
|
||||
|
||||
-> The `hax` accelerator has issues attaching CDROM ISOs. This is an
|
||||
upstream issue which can be tracked
|
||||
[here](https://github.com/intel/haxm/issues/20).
|
||||
## Specific Configuration Reference
|
||||
|
||||
-> The `hvf` and `whpx` accelerator are new and experimental as of
|
||||
[QEMU 2.12.0](https://wiki.qemu.org/ChangeLog/2.12#Host_support).
|
||||
You may encounter issues unrelated to Packer when using these. You may need to
|
||||
add [ "-global", "virtio-pci.disable-modern=on" ] to `qemuargs` depending on the
|
||||
guest operating system.
|
||||
|
||||
-> For `whpx`, note that [Stefan Weil's QEMU for Windows distribution](https://qemu.weilnetz.de/w64/)
|
||||
does not include WHPX support and users may need to compile or source a
|
||||
build of QEMU for Windows themselves with WHPX support.
|
||||
### Optional:
|
||||
<%= partial "partials/builder/qemu/Config-not-required" %>
|
||||
DADA
|
||||
|
||||
- `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
|
||||
|
@ -139,46 +109,6 @@ Linux server and have not enabled X11 forwarding (`ssh -X`).
|
|||
five seconds and one minute 30 seconds, respectively. If this isn't
|
||||
specified, the default is `10s` or 10 seconds.
|
||||
|
||||
- `cpus` (number) - The number of cpus to use when building the VM.
|
||||
The default is `1` CPU.
|
||||
|
||||
- `disk_cache` (string) - The cache mode to use for disk. Allowed values
|
||||
include any of `writethrough`, `writeback`, `none`, `unsafe`
|
||||
or `directsync`. By default, this is set to `writeback`.
|
||||
|
||||
- `disk_compression` (boolean) - Apply compression to the QCOW2 disk file
|
||||
using `qemu-img convert`. Defaults to `false`.
|
||||
|
||||
- `disk_discard` (string) - The discard mode to use for disk. Allowed values
|
||||
include any of `unmap` or `ignore`. By default, this is set to `ignore`.
|
||||
|
||||
- `disk_detect_zeroes` (string) - The detect-zeroes mode to use for disk.
|
||||
Allowed values include any of `unmap`, `on` or `off`. Defaults to `off`.
|
||||
When the value is "off" we don't set the flag in the qemu command, so that
|
||||
Packer still works with old versions of QEMU that don't have this option.
|
||||
|
||||
- `disk_image` (boolean) - Packer defaults to building from an ISO file, this
|
||||
parameter controls whether the ISO URL supplied is actually a bootable
|
||||
QEMU image. When this value is set to `true`, the machine will either clone
|
||||
the source or use it as a backing file (if `use_backing_file` is `true`);
|
||||
then, it will resize the image according to `disk_size` and boot it.
|
||||
|
||||
- `disk_interface` (string) - The interface to use for the disk. Allowed
|
||||
values include any of `ide`, `scsi`, `virtio` or `virtio-scsi`^\*. Note
|
||||
also that any boot commands or kickstart type scripts must have proper
|
||||
adjustments for resulting device names. The Qemu builder uses `virtio` by
|
||||
default.
|
||||
|
||||
^\* Please be aware that use of the `scsi` disk interface has been disabled
|
||||
by Red Hat due to a bug described
|
||||
[here](https://bugzilla.redhat.com/show_bug.cgi?id=1019220).
|
||||
If you are running Qemu on RHEL or a RHEL variant such as CentOS, you
|
||||
*must* choose one of the other listed interfaces. Using the `scsi`
|
||||
interface under these circumstances will cause the build to fail.
|
||||
|
||||
- `disk_size` (number) - The size, in megabytes, of the hard disk to create
|
||||
for the VM. By default, this is `40960` (40 GB).
|
||||
|
||||
- `floppy_dirs` (array of strings) - A list of directories to place onto
|
||||
the floppy disk recursively. This is similar to the `floppy_files` option
|
||||
except that the directory structure is preserved. This is useful for when
|
||||
|
@ -199,16 +129,6 @@ Linux server and have not enabled X11 forwarding (`ssh -X`).
|
|||
listed files must not exceed 1.44 MB. The supported ways to move large
|
||||
files into the OS are using `http_directory` or [the file provisioner](https://www.packer.io/docs/provisioners/file.html).
|
||||
|
||||
- `format` (string) - Either `qcow2` or `raw`, this specifies the output
|
||||
format of the virtual machine image. This defaults to `qcow2`.
|
||||
|
||||
- `headless` (boolean) - Packer defaults to building QEMU virtual machines by
|
||||
launching a GUI that shows the console of the machine being built. When this
|
||||
value is set to `true`, the machine will start without a console.
|
||||
|
||||
You can still see the console if you make a note of the VNC display
|
||||
number chosen, and then connect using `vncviewer -Shared <host>:<display>`
|
||||
|
||||
- `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 be requestable from the virtual machine. This is useful for hosting
|
||||
|
@ -224,162 +144,6 @@ Linux server and have not enabled X11 forwarding (`ssh -X`).
|
|||
to force the HTTP server to be on one port, make this minimum and maximum
|
||||
port the same. By default the values are `8000` and `9000`, respectively.
|
||||
|
||||
- `iso_skip_cache` (boolean) - Use iso from provided url. Qemu must support
|
||||
curl block device. This defaults to `false`.
|
||||
|
||||
- `iso_target_extension` (string) - The extension of the iso file after
|
||||
download. This defaults to `iso`.
|
||||
|
||||
- `iso_target_path` (string) - The path where the iso should be saved after
|
||||
download. By default will go in the packer cache, with a hash of the
|
||||
original filename as its name.
|
||||
|
||||
- `iso_urls` (array of strings) - Multiple URLs for the ISO to download.
|
||||
Packer will try these in order. If anything goes wrong attempting to
|
||||
download or while downloading a single URL, it will move on to the next. All
|
||||
URLs must point to the same file (same checksum). By default this is empty
|
||||
and `iso_url` is used. Only one of `iso_url` or `iso_urls` can be specified.
|
||||
|
||||
- `machine_type` (string) - The type of machine emulation to use. Run your
|
||||
qemu binary with the flags `-machine help` to list available types for
|
||||
your system. This defaults to `pc`.
|
||||
|
||||
- `memory` (number) - The amount of memory to use when building the VM
|
||||
in megabytes. This defaults to `512` megabytes.
|
||||
|
||||
- `net_device` (string) - The driver to use for the network interface. Allowed
|
||||
values `ne2k_pci`, `i82551`, `i82557b`, `i82559er`, `rtl8139`, `e1000`,
|
||||
`pcnet`, `virtio`, `virtio-net`, `virtio-net-pci`, `usb-net`, `i82559a`,
|
||||
`i82559b`, `i82559c`, `i82550`, `i82562`, `i82557a`, `i82557c`, `i82801`,
|
||||
`vmxnet3`, `i82558a` or `i82558b`. The Qemu builder uses `virtio-net` by
|
||||
default.
|
||||
|
||||
- `output_directory` (string) - This is the path to the directory where the
|
||||
resulting virtual machine will be created. This may be relative or absolute.
|
||||
If relative, the path is relative to the working directory when `packer`
|
||||
is executed. This directory must not exist or be empty prior to running
|
||||
the builder. By default this is `output-BUILDNAME` where "BUILDNAME" is the
|
||||
name of the build.
|
||||
|
||||
- `qemu_binary` (string) - The name of the Qemu binary to look for. This
|
||||
defaults to `qemu-system-x86_64`, but may need to be changed for
|
||||
some platforms. For example `qemu-kvm`, or `qemu-system-i386` may be a
|
||||
better choice for some systems.
|
||||
|
||||
- `qemuargs` (array of array of strings) - Allows complete control over the
|
||||
qemu command line (though not, at this time, qemu-img). Each array of
|
||||
strings makes up a command line switch that overrides matching default
|
||||
switch/value pairs. Any value specified as an empty string is ignored. All
|
||||
values after the switch are concatenated with no separator.
|
||||
|
||||
~> **Warning:** The qemu command line allows extreme flexibility, so beware
|
||||
of conflicting arguments causing failures of your run. For instance, using
|
||||
--no-acpi could break the ability to send power signal type commands (e.g.,
|
||||
shutdown -P now) to the virtual machine, thus preventing proper shutdown. To see
|
||||
the defaults, look in the packer.log file and search for the qemu-system-x86
|
||||
command. The arguments are all printed for review.
|
||||
|
||||
The following shows a sample usage:
|
||||
|
||||
``` json
|
||||
{
|
||||
"qemuargs": [
|
||||
[ "-m", "1024M" ],
|
||||
[ "--no-acpi", "" ],
|
||||
[
|
||||
"-netdev",
|
||||
"user,id=mynet0,",
|
||||
"hostfwd=hostip:hostport-guestip:guestport",
|
||||
""
|
||||
],
|
||||
[ "-device", "virtio-net,netdev=mynet0" ]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
would produce the following (not including other defaults supplied by the
|
||||
builder and not otherwise conflicting with the qemuargs):
|
||||
|
||||
``` text
|
||||
qemu-system-x86 -m 1024m --no-acpi -netdev user,id=mynet0,hostfwd=hostip:hostport-guestip:guestport -device virtio-net,netdev=mynet0"
|
||||
```
|
||||
|
||||
~> **Windows Users:** [QEMU for Windows](https://qemu.weilnetz.de/) builds are available though an environmental variable does need
|
||||
to be set for QEMU for Windows to redirect stdout to the console instead of stdout.txt.
|
||||
|
||||
The following shows the environment variable that needs to be set for Windows QEMU support:
|
||||
|
||||
``` text
|
||||
setx SDL_STDIO_REDIRECT=0
|
||||
```
|
||||
|
||||
You can also use the `SSHHostPort` template variable to produce a packer
|
||||
template that can be invoked by `make` in parallel:
|
||||
|
||||
``` json
|
||||
{
|
||||
"qemuargs": [
|
||||
[ "-netdev", "user,hostfwd=tcp::{{ .SSHHostPort }}-:22,id=forward"],
|
||||
[ "-device", "virtio-net,netdev=forward,id=net0"]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`make -j 3 my-awesome-packer-templates` spawns 3 packer processes, each of which
|
||||
will bind to their own SSH port as determined by each process. This will also
|
||||
work with WinRM, just change the port forward in `qemuargs` to map to WinRM's
|
||||
default port of `5985` or whatever value you have the service set to listen on.
|
||||
|
||||
- `use_backing_file` (boolean) - Only applicable when `disk_image` is `true`
|
||||
and `format` is `qcow2`, set this option to `true` to create a new QCOW2
|
||||
file that uses the file located at `iso_url` as a backing file. The new file
|
||||
will only contain blocks that have changed compared to the backing file, so
|
||||
enabling this option can significantly reduce disk usage.
|
||||
|
||||
- `use_default_display` (boolean) - If true, do not pass a `-display` option
|
||||
to qemu, allowing it to choose the default. This may be needed when running
|
||||
under macOS, and getting errors about `sdl` not being available.
|
||||
|
||||
- `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
|
||||
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. It
|
||||
is important to add a `shutdown_command`. By default Packer halts the virtual
|
||||
machine and the file system may not be sync'd. Thus, changes made in a
|
||||
provisioner might not be saved. If one or more scripts require a reboot it is
|
||||
suggested to leave this blank since reboots may fail and specify the final
|
||||
shutdown command in your last script.
|
||||
|
||||
- `shutdown_timeout` (string) - The amount of time to wait after executing the
|
||||
`shutdown_command` for the virtual machine to actually shut down. If it
|
||||
doesn't shut down in this time, it is an error. By default, the timeout is
|
||||
`5m` or five minutes.
|
||||
|
||||
- `skip_compaction` (boolean) - Packer compacts the QCOW2 image using
|
||||
`qemu-img convert`. Set this option to `true` to disable compacting.
|
||||
Defaults to `false`.
|
||||
|
||||
- `ssh_host_port_min` and `ssh_host_port_max` (number) - The minimum and
|
||||
maximum port to use for the SSH port on the host machine which is forwarded
|
||||
to the SSH port on the guest machine. Because Packer often runs in parallel,
|
||||
Packer will choose a randomly available port in this range to use as the
|
||||
host port. By default this is `2222` to `4444`.
|
||||
|
||||
- `vm_name` (string) - This is the name of the image (QCOW2 or IMG) file for
|
||||
the new virtual machine. By default this is `packer-BUILDNAME`, where
|
||||
"BUILDNAME" is the name of the build. Currently, no file extension will be
|
||||
used unless it is specified in this option.
|
||||
|
||||
- `vnc_bind_address` (string / IP address) - The IP address that should be
|
||||
binded to for VNC. By default packer will use `127.0.0.1` for this. If you
|
||||
wish to bind to all interfaces use `0.0.0.0`.
|
||||
|
||||
- `vnc_port_min` and `vnc_port_max` (number) - The minimum and maximum port
|
||||
to use for VNC access to the virtual machine. The builder uses VNC to type
|
||||
the initial `boot_command`. Because Packer generally runs in parallel,
|
||||
Packer uses a randomly chosen port in this range that appears available. By
|
||||
default this is `5900` to `6000`. The minimum and maximum ports are inclusive.
|
||||
|
||||
## Boot Command
|
||||
|
||||
The `boot_command` configuration is very important: it specifies the keys to
|
||||
|
|
|
@ -4,13 +4,27 @@
|
|||
curl block device. This defaults to false.
|
||||
|
||||
- `accelerator` (string) - The accelerator type to use when running the VM.
|
||||
This may be none, kvm, tcg, hax, hvf, whpx, or xen. The appropriate
|
||||
This may be `none`, `kvm`, `tcg`, `hax`, `hvf`, `whpx`, or `xen`. The appropriate
|
||||
software must have already been installed on your build machine to use the
|
||||
accelerator you specified. When no accelerator is specified, Packer will try
|
||||
to use kvm if it is available but will default to tcg otherwise.
|
||||
to use `kvm` if it is available but will default to `tcg` otherwise.
|
||||
|
||||
-> The `hax` accelerator has issues attaching CDROM ISOs. This is an
|
||||
upstream issue which can be tracked
|
||||
[here](https://github.com/intel/haxm/issues/20).
|
||||
|
||||
-> The `hvf` and `whpx` accelerator are new and experimental as of
|
||||
[QEMU 2.12.0](https://wiki.qemu.org/ChangeLog/2.12#Host_support).
|
||||
You may encounter issues unrelated to Packer when using these. You may need to
|
||||
add [ "-global", "virtio-pci.disable-modern=on" ] to `qemuargs` depending on the
|
||||
guest operating system.
|
||||
|
||||
-> For `whpx`, note that [Stefan Weil's QEMU for Windows distribution](https://qemu.weilnetz.de/w64/)
|
||||
does not include WHPX support and users may need to compile or source a
|
||||
build of QEMU for Windows themselves with WHPX support.
|
||||
|
||||
- `cpus` (int) - The number of cpus to use when building the VM.
|
||||
The default is 1 CPU.
|
||||
The default is `1` CPU.
|
||||
|
||||
- `disk_interface` (string) - The interface to use for the disk. Allowed
|
||||
values include any of ide, scsi, virtio or virtio-scsi*. Note
|
||||
|
@ -21,9 +35,9 @@
|
|||
- `disk_size` (uint) - The size, in megabytes, of the hard disk to create
|
||||
for the VM. By default, this is 40960 (40 GB).
|
||||
|
||||
- `disk_cache` (string) - The cache mode to use for disk. Allowed values
|
||||
include any of writethrough, writeback, none, unsafe
|
||||
or directsync. By default, this is set to writeback.
|
||||
- `disk_cache` (string) - The cache mode to use for disk. Allowed values include any of
|
||||
`writethrough`, `writeback`, `none`, `unsafe` or `directsync`. By
|
||||
default, this is set to `writeback`.
|
||||
|
||||
- `disk_discard` (string) - The discard mode to use for disk. Allowed values
|
||||
include any of unmap or ignore. By default, this is set to ignore.
|
||||
|
@ -47,11 +61,11 @@
|
|||
launching a GUI that shows the console of the machine being built. When this
|
||||
value is set to true, the machine will start without a console.
|
||||
|
||||
- `disk_image` (bool) - Packer defaults to building from an ISO file, this
|
||||
parameter controls whether the ISO URL supplied is actually a bootable
|
||||
QEMU image. When this value is set to true, the machine will either clone
|
||||
the source or use it as a backing file (if use_backing_file is true);
|
||||
then, it will resize the image according to disk_size and boot it.
|
||||
- `disk_image` (bool) - Packer defaults to building from an ISO file, this parameter controls
|
||||
whether the ISO URL supplied is actually a bootable QEMU image. When
|
||||
this value is set to `true`, the machine will either clone the source or
|
||||
use it as a backing file (if `use_backing_file` is `true`); then, it
|
||||
will resize the image according to `disk_size` and boot it.
|
||||
|
||||
- `use_backing_file` (bool) - Only applicable when disk_image is true
|
||||
and format is qcow2, set this option to true to create a new QCOW2
|
||||
|
@ -91,16 +105,6 @@
|
|||
some platforms. For example qemu-kvm, or qemu-system-i386 may be a
|
||||
better choice for some systems.
|
||||
|
||||
- `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
|
||||
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. It
|
||||
is important to add a shutdown_command. By default Packer halts the virtual
|
||||
machine and the file system may not be sync'd. Thus, changes made in a
|
||||
provisioner might not be saved. If one or more scripts require a reboot it is
|
||||
suggested to leave this blank since reboots may fail and specify the final
|
||||
shutdown command in your last script.
|
||||
|
||||
- `ssh_host_port_min` (int) - The minimum and
|
||||
maximum port to use for the SSH port on the host machine which is forwarded
|
||||
to the SSH port on the guest machine. Because Packer often runs in parallel,
|
||||
|
@ -132,9 +136,4 @@
|
|||
TODO(@mitchellh): remove
|
||||
|
||||
- `run_once` (bool) - TODO(mitchellh): deprecate
|
||||
|
||||
- `shutdown_timeout` (string) - The amount of time to wait after executing the
|
||||
shutdown_command for the virtual machine to actually shut down. If it
|
||||
doesn't shut down in this time, it is an error. By default, the timeout is
|
||||
5m or five minutes.
|
||||
|
Loading…
Reference in New Issue