2013-12-22 15:44:43 -08:00
|
|
|
---
|
2018-04-13 19:48:19 -07:00
|
|
|
modeline: |
|
|
|
|
vim: set ft=pandoc:
|
2017-06-14 18:04:16 -07:00
|
|
|
description: |
|
2020-03-18 18:46:47 -04:00
|
|
|
This VirtualBox Packer builder is able to create VirtualBox virtual machines
|
|
|
|
and export them in the OVF format, starting from an existing OVF/OVA (exported
|
|
|
|
virtual machine image).
|
|
|
|
page_title: VirtualBox OVF/OVA - Builders
|
2017-03-25 18:13:52 -04:00
|
|
|
---
|
2013-12-22 15:44:43 -08:00
|
|
|
|
|
|
|
# VirtualBox Builder (from an OVF/OVA)
|
|
|
|
|
|
|
|
Type: `virtualbox-ovf`
|
2021-02-05 16:49:28 -08:00
|
|
|
Artifact BuilderId: `mitchellh.virtualbox`
|
2013-12-22 15:44:43 -08:00
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
This VirtualBox Packer builder is able to create
|
|
|
|
[VirtualBox](https://www.virtualbox.org/) virtual machines and export them in
|
|
|
|
the OVF format, starting from an existing OVF/OVA (exported virtual machine
|
|
|
|
image).
|
2013-12-22 15:44:43 -08:00
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
When exporting from VirtualBox make sure to choose OVF Version 2, since Version
|
|
|
|
1 is not compatible and will generate errors like this:
|
2015-02-19 15:42:35 -08:00
|
|
|
|
2020-05-29 17:12:05 -04:00
|
|
|
```shell-session
|
2020-03-27 14:22:33 -04:00
|
|
|
==> virtualbox-ovf: Progress state: VBOX_E_FILE_ERROR
|
|
|
|
==> virtualbox-ovf: VBoxManage: error: Appliance read failed
|
|
|
|
==> virtualbox-ovf: VBoxManage: error: Error reading "source.ova": element "Section" has no "type" attribute, line 21
|
|
|
|
==> virtualbox-ovf: VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Appliance, interface IAppliance
|
|
|
|
==> virtualbox-ovf: VBoxManage: error: Context: "int handleImportAppliance(HandlerArg*)" at line 304 of file VBoxManageAppliance.cpp
|
|
|
|
```
|
2015-02-19 15:42:35 -08:00
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
The builder builds a virtual machine by importing an existing OVF or OVA file.
|
|
|
|
It then boots this image, runs provisioners on this new VM, and exports that VM
|
|
|
|
to create the image. The imported machine is deleted prior to finishing the
|
|
|
|
build.
|
2013-12-22 15:44:43 -08:00
|
|
|
|
|
|
|
## Basic Example
|
|
|
|
|
|
|
|
Here is a basic example. This example is functional if you have an OVF matching
|
|
|
|
the settings here.
|
|
|
|
|
2020-06-16 16:56:07 +02:00
|
|
|
<Tabs>
|
|
|
|
<Tab heading="JSON">
|
|
|
|
|
2020-03-12 10:05:08 -04:00
|
|
|
```json
|
2013-12-22 15:44:43 -08:00
|
|
|
{
|
|
|
|
"type": "virtualbox-ovf",
|
|
|
|
"source_path": "source.ovf",
|
|
|
|
"ssh_username": "packer",
|
|
|
|
"ssh_password": "packer",
|
|
|
|
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
|
|
|
|
}
|
2014-10-20 13:55:16 -04:00
|
|
|
```
|
2013-12-22 15:44:43 -08:00
|
|
|
|
2020-06-16 16:56:07 +02:00
|
|
|
</Tab>
|
|
|
|
<Tab heading="HCL2">
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
source "virtualbox-ovf" "basic-example" {
|
|
|
|
source_path = "source.ovf"
|
|
|
|
ssh_username = "packer"
|
|
|
|
ssh_password = "packer"
|
|
|
|
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
|
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
|
|
|
sources = ["sources.virtualbox-ovf.basic-example"]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
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
|
2013-12-22 15:44:43 -08:00
|
|
|
provisioner might not be saved.
|
|
|
|
|
|
|
|
## Configuration Reference
|
|
|
|
|
2019-06-19 17:37:52 +02:00
|
|
|
There are many configuration options available for the builder. In addition to
|
|
|
|
the items listed here, you will want to look at the general configuration
|
|
|
|
references for [ISO](#iso-configuration),
|
|
|
|
[HTTP](#http-directory-configuration),
|
|
|
|
[Floppy](#floppy-configuration),
|
|
|
|
[Export](#export-configuration),
|
|
|
|
[Boot](#boot-configuration),
|
|
|
|
[Shutdown](#shutdown-configuration),
|
|
|
|
[Run](#run-configuration),
|
|
|
|
[Communicator](#communicator-configuration)
|
|
|
|
configuration references, which are
|
|
|
|
necessary for this build to succeed and can be found further down the page.
|
2015-06-23 14:44:57 -07:00
|
|
|
|
2014-05-04 10:47:40 -07:00
|
|
|
### Required:
|
2013-12-22 15:44:43 -08:00
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/ovf/Config-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
|
|
|
#### Optional:
|
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/ovf/Config-not-required.mdx'
|
2020-03-24 19:48:37 -04:00
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/common/VBoxVersionConfig-not-required.mdx'
|
2020-03-24 19:48:37 -04:00
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/common/GuestAdditionsConfig-not-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
2020-03-10 03:11:27 -07:00
|
|
|
### VBoxManage configuration
|
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/common/VBoxManageConfig-not-required.mdx'
|
2020-03-10 03:11:27 -07:00
|
|
|
|
2019-06-19 17:37:52 +02:00
|
|
|
### Http directory configuration
|
|
|
|
|
2020-11-17 17:18:45 -08:00
|
|
|
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig.mdx'
|
2020-03-18 18:46:47 -04:00
|
|
|
|
2019-06-19 17:37:52 +02:00
|
|
|
#### Optional:
|
|
|
|
|
2020-11-17 17:18:45 -08:00
|
|
|
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig-not-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
|
|
|
### Floppy configuration
|
|
|
|
|
2020-11-17 17:18:45 -08:00
|
|
|
@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
|
|
|
#### Optional:
|
|
|
|
|
2020-11-17 17:18:45 -08:00
|
|
|
@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig-not-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
2020-09-14 11:03:07 -07:00
|
|
|
### CD configuration
|
|
|
|
|
2020-11-17 17:18:45 -08:00
|
|
|
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig.mdx'
|
2020-09-14 11:03:07 -07:00
|
|
|
|
|
|
|
#### Optional:
|
|
|
|
|
2020-11-17 17:07:02 -08:00
|
|
|
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig-not-required.mdx'
|
2020-09-14 11:03:07 -07:00
|
|
|
|
2019-06-19 17:37:52 +02:00
|
|
|
### Export configuration
|
|
|
|
|
|
|
|
#### Optional:
|
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/common/ExportConfig-not-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
|
|
|
### Output configuration
|
|
|
|
|
|
|
|
#### Optional:
|
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/common/OutputConfig-not-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
|
|
|
### Run configuration
|
|
|
|
|
|
|
|
#### Optional:
|
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/common/RunConfig-not-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
|
|
|
### Shutdown configuration
|
|
|
|
|
|
|
|
#### Optional:
|
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/common/ShutdownConfig-not-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
2019-06-20 12:22:26 +02:00
|
|
|
### Communicator configuration
|
|
|
|
|
|
|
|
#### Optional common fields:
|
|
|
|
|
2020-12-01 15:30:31 -08:00
|
|
|
@include 'packer-plugin-sdk/communicator/Config-not-required.mdx'
|
2020-03-24 19:48:37 -04:00
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builder/virtualbox/common/CommConfig-not-required.mdx'
|
2019-06-20 12:22:26 +02:00
|
|
|
|
|
|
|
#### Optional SSH fields:
|
|
|
|
|
2020-12-01 15:30:31 -08:00
|
|
|
@include 'packer-plugin-sdk/communicator/SSH-not-required.mdx'
|
2019-06-20 12:22:26 +02:00
|
|
|
|
2020-12-01 15:30:31 -08:00
|
|
|
@include 'packer-plugin-sdk/communicator/SSHTemporaryKeyPair-not-required.mdx'
|
2020-07-02 14:50:45 +02:00
|
|
|
|
2020-12-01 15:30:31 -08:00
|
|
|
@include 'packer-plugin-sdk/communicator/SSH-Key-Pair-Name-not-required.mdx'
|
2020-07-02 14:50:45 +02:00
|
|
|
|
2020-12-01 15:30:31 -08:00
|
|
|
@include 'packer-plugin-sdk/communicator/SSH-Private-Key-File-not-required.mdx'
|
2020-07-02 14:50:45 +02:00
|
|
|
|
2020-12-01 15:30:31 -08:00
|
|
|
@include 'packer-plugin-sdk/communicator/SSH-Agent-Auth-not-required.mdx'
|
2020-07-01 14:32:26 +02:00
|
|
|
|
2019-06-20 12:22:26 +02:00
|
|
|
#### Optional WinRM fields:
|
|
|
|
|
2020-12-01 15:30:31 -08:00
|
|
|
@include 'packer-plugin-sdk/communicator/WinRM-not-required.mdx'
|
2019-06-20 12:22:26 +02:00
|
|
|
|
2019-06-19 17:37:52 +02:00
|
|
|
### Boot Configuration
|
|
|
|
|
2020-11-12 14:44:02 -08:00
|
|
|
@include 'packer-plugin-sdk/bootcommand/BootConfig.mdx'
|
2016-08-02 21:58:04 +01:00
|
|
|
|
2020-06-12 12:42:00 +02:00
|
|
|
Please note that for the Virtuabox builder, the IP address of the HTTP server
|
|
|
|
Packer launches for you to access files like the preseed file in the example
|
|
|
|
above (`{{ .HTTPIP }}`) is hardcoded to 10.0.2.2. If you change the network
|
|
|
|
of your VM you must guarantee that you can still access this HTTP server.
|
|
|
|
|
2018-04-13 16:48:26 -07:00
|
|
|
The boot command is sent to the VM through the `VBoxManage` utility in as few
|
2018-05-23 15:24:18 -07:00
|
|
|
invocations as possible. We send each character in groups of 25, with a default
|
|
|
|
delay of 100ms between groups. The delay alleviates issues with latency and CPU
|
2018-08-22 11:25:43 -07:00
|
|
|
contention. If you notice missing keys, you can tune this delay by specifying
|
|
|
|
"boot_keygroup_interval" in your Packer template, for example:
|
|
|
|
|
2020-08-20 15:43:38 +02:00
|
|
|
<Tabs>
|
|
|
|
<Tab heading="JSON">
|
|
|
|
|
2020-03-12 10:05:08 -04:00
|
|
|
```json
|
2018-08-22 11:25:43 -07:00
|
|
|
{
|
|
|
|
"builders": [
|
|
|
|
{
|
2020-08-20 15:43:38 +02:00
|
|
|
"type": "virtualbox-ovf",
|
2019-06-19 17:37:52 +02:00
|
|
|
"boot_keygroup_interval": "500ms"
|
2018-08-22 11:25:43 -07:00
|
|
|
...
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-08-20 15:43:38 +02:00
|
|
|
</Tab>
|
|
|
|
<Tab heading="HCL2">
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
source "virtualbox-ovf" "basic-example" {
|
|
|
|
boot_keygroup_interval = "500ms"
|
|
|
|
# ...
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
|
2019-06-19 17:37:52 +02:00
|
|
|
#### Optional:
|
|
|
|
|
2020-11-12 14:44:02 -08:00
|
|
|
@include 'packer-plugin-sdk/bootcommand/BootConfig-not-required.mdx'
|
2019-06-19 17:37:52 +02:00
|
|
|
|
2020-03-23 20:02:12 -04:00
|
|
|
@include 'builders/virtualbox-ssh-key-pair.mdx'
|
2019-02-06 16:03:40 -05:00
|
|
|
|
2013-12-22 15:44:43 -08:00
|
|
|
## Guest Additions
|
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
Packer will automatically download the proper guest additions for the version of
|
|
|
|
VirtualBox that is running and upload those guest additions into the virtual
|
|
|
|
machine so that provisioners can easily install them.
|
2013-12-22 15:44:43 -08:00
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
Packer downloads the guest additions from the official VirtualBox website, and
|
|
|
|
verifies the file with the official checksums released by VirtualBox.
|
2013-12-22 15:44:43 -08:00
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
After the virtual machine is up and the operating system is installed, Packer
|
|
|
|
uploads the guest additions into the virtual machine. The path where they are
|
|
|
|
uploaded is controllable by `guest_additions_path`, and defaults to
|
|
|
|
"VBoxGuestAdditions.iso". Without an absolute path, it is uploaded to the home
|
|
|
|
directory of the SSH user.
|
2013-12-22 15:44:43 -08:00
|
|
|
|
|
|
|
## VBoxManage Commands
|
|
|
|
|
2020-08-20 15:43:38 +02:00
|
|
|
@include 'builder/virtualbox/common/VBoxManageConfig.mdx'
|
2013-12-22 15:44:43 -08:00
|
|
|
|
2020-08-20 15:43:38 +02:00
|
|
|
@include 'builder/virtualbox/common/VBoxManageConfig-not-required.mdx'
|