add qemu hcl examples
This commit is contained in:
parent
fe7f529862
commit
fc2e94554a
|
@ -86,17 +86,17 @@ type Config struct {
|
|||
// accelerator you specified. When no accelerator is specified, Packer will try
|
||||
// to use `kvm` if it is available but will default to `tcg` otherwise.
|
||||
//
|
||||
// -> The `hax` accelerator has issues attaching CDROM ISOs. This is an
|
||||
// ~> 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
|
||||
// ~> 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/)
|
||||
// ~> 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"`
|
||||
|
@ -208,7 +208,7 @@ type Config struct {
|
|||
// 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
|
||||
// ~> **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
|
||||
|
@ -218,8 +218,8 @@ type Config struct {
|
|||
//
|
||||
// The following shows a sample usage:
|
||||
//
|
||||
// In JSON:
|
||||
// ```json
|
||||
//{
|
||||
// "qemuargs": [
|
||||
// [ "-m", "1024M" ],
|
||||
// [ "--no-acpi", "" ],
|
||||
|
@ -231,7 +231,21 @@ type Config struct {
|
|||
// ],
|
||||
// [ "-device", "virtio-net,netdev=mynet0" ]
|
||||
// ]
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// In HCL2:
|
||||
// ```hcl
|
||||
// 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
|
||||
|
@ -243,7 +257,7 @@ type Config struct {
|
|||
// virtio-net,netdev=mynet0"
|
||||
// ```
|
||||
//
|
||||
// ~> **Windows Users:** [QEMU for Windows](https://qemu.weilnetz.de/)
|
||||
// ~> **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.
|
||||
|
@ -258,15 +272,21 @@ type Config struct {
|
|||
// You can also use the `SSHHostPort` template variable to produce a packer
|
||||
// template that can be invoked by `make` in parallel:
|
||||
//
|
||||
// In JSON:
|
||||
// ```json
|
||||
//{
|
||||
// "qemuargs": [
|
||||
// [ "-netdev", "user,hostfwd=tcp::{{ .SSHHostPort }}-:22,id=forward"],
|
||||
// [ "-device", "virtio-net,netdev=forward,id=net0"]
|
||||
// ]
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// In HCL2:
|
||||
// ```hcl
|
||||
// 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
|
||||
|
|
|
@ -26,14 +26,16 @@ necessary to run the virtual machine on KVM or Xen.
|
|||
Here is a basic example. This example is functional so long as you fixup paths
|
||||
to files, URLS for ISOs and checksums.
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "qemu",
|
||||
"iso_url": "http://mirror.raystedman.net/centos/6/isos/x86_64/CentOS-6.9-x86_64-minimal.iso",
|
||||
"iso_checksum": "af4a1640c0c6f348c6c41f1ea9e192a2",
|
||||
"iso_checksum_type": "md5",
|
||||
"iso_checksum": "md5:af4a1640c0c6f348c6c41f1ea9e192a2",
|
||||
"output_directory": "output_centos_tdhtest",
|
||||
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
|
||||
"disk_size": "5000M",
|
||||
|
@ -55,6 +57,37 @@ to files, URLS for ISOs and checksums.
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "qemu" "example" {
|
||||
iso_url = "http://mirror.raystedman.net/centos/6/isos/x86_64/CentOS-6.9-x86_64-minimal.iso"
|
||||
iso_checksum = "md5:af4a1640c0c6f348c6c41f1ea9e192a2"
|
||||
output_directory = "output_centos_tdhtest"
|
||||
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
|
||||
disk_size = "5000M"
|
||||
format = "qcow2"
|
||||
accelerator = "kvm"
|
||||
http_directory = "path/to/httpdir"
|
||||
ssh_username = "root"
|
||||
ssh_password = "s0m3password"
|
||||
ssh_timeout = "20m"
|
||||
vm_name = "tdhtest"
|
||||
net_device = "virtio-net"
|
||||
disk_interface = "virtio"
|
||||
boot_wait = "10s"
|
||||
boot_command = ["<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6-ks.cfg<enter><wait>"]
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.qemu.example"]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
This is an example only, and will time out waiting for SSH because we have not
|
||||
provided a kickstart file. You must add a valid kickstart file to the
|
||||
"http_directory" and then provide the file in the "boot_command" in order for
|
||||
|
|
|
@ -9,17 +9,17 @@
|
|||
accelerator you specified. When no accelerator is specified, Packer will try
|
||||
to use `kvm` if it is available but will default to `tcg` otherwise.
|
||||
|
||||
-> The `hax` accelerator has issues attaching CDROM ISOs. This is an
|
||||
~> 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
|
||||
~> 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/)
|
||||
~> 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.
|
||||
|
||||
|
@ -131,7 +131,7 @@
|
|||
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
|
||||
~> **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
|
||||
|
@ -141,8 +141,8 @@
|
|||
|
||||
The following shows a sample usage:
|
||||
|
||||
In JSON:
|
||||
```json
|
||||
{
|
||||
"qemuargs": [
|
||||
[ "-m", "1024M" ],
|
||||
[ "--no-acpi", "" ],
|
||||
|
@ -154,7 +154,21 @@
|
|||
],
|
||||
[ "-device", "virtio-net,netdev=mynet0" ]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
In HCL2:
|
||||
```hcl
|
||||
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
|
||||
|
@ -166,7 +180,7 @@
|
|||
virtio-net,netdev=mynet0"
|
||||
```
|
||||
|
||||
~> **Windows Users:** [QEMU for Windows](https://qemu.weilnetz.de/)
|
||||
~> **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.
|
||||
|
@ -181,15 +195,21 @@
|
|||
You can also use the `SSHHostPort` template variable to produce a packer
|
||||
template that can be invoked by `make` in parallel:
|
||||
|
||||
In JSON:
|
||||
```json
|
||||
{
|
||||
"qemuargs": [
|
||||
[ "-netdev", "user,hostfwd=tcp::{{ .SSHHostPort }}-:22,id=forward"],
|
||||
[ "-device", "virtio-net,netdev=forward,id=net0"]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
In HCL2:
|
||||
```hcl
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue