2013-06-27 11:17:00 -04:00
|
|
|
---
|
2017-06-14 21:04:16 -04:00
|
|
|
description: |
|
|
|
|
The Packer Vagrant post-processor takes a build and converts the artifact into
|
|
|
|
a valid Vagrant box, if it can. This lets you use Packer to automatically
|
|
|
|
create arbitrarily complex Vagrant boxes, and is in fact how the official
|
|
|
|
boxes distributed by Vagrant are created.
|
2015-07-22 22:31:00 -04:00
|
|
|
layout: docs
|
2017-06-14 21:04:16 -04:00
|
|
|
page_title: 'Vagrant - Post-Processors'
|
|
|
|
sidebar_current: 'docs-post-processors-vagrant-box'
|
2017-03-25 18:13:52 -04:00
|
|
|
---
|
2013-06-27 11:17:00 -04:00
|
|
|
|
|
|
|
# Vagrant Post-Processor
|
|
|
|
|
|
|
|
Type: `vagrant`
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
The Packer Vagrant post-processor takes a build and converts the artifact into a
|
2016-01-14 15:31:19 -05:00
|
|
|
valid [Vagrant](https://www.vagrantup.com) box, if it can. This lets you use
|
2015-07-22 22:31:00 -04:00
|
|
|
Packer to automatically create arbitrarily complex Vagrant boxes, and is in fact
|
|
|
|
how the official boxes distributed by Vagrant are created.
|
2013-06-27 11:17:00 -04:00
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
If you've never used a post-processor before, please read the documentation on
|
|
|
|
[using post-processors](/docs/templates/post-processors.html) in templates. This
|
|
|
|
knowledge will be expected for the remainder of this document.
|
2013-06-27 11:17:00 -04:00
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
Because Vagrant boxes are
|
2016-01-14 15:31:19 -05:00
|
|
|
[provider-specific](https://docs.vagrantup.com/v2/boxes/format.html), the Vagrant
|
2015-07-22 22:31:00 -04:00
|
|
|
post-processor is hardcoded to understand how to convert the artifacts of
|
|
|
|
certain builders into proper boxes for their respective providers.
|
2013-06-27 11:17:00 -04:00
|
|
|
|
|
|
|
Currently, the Vagrant post-processor can create boxes for the following
|
|
|
|
providers.
|
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
- AWS
|
|
|
|
- DigitalOcean
|
2017-12-23 01:13:17 -05:00
|
|
|
- Google
|
2017-06-14 21:04:16 -04:00
|
|
|
- Hyper-V
|
2018-03-06 15:02:19 -05:00
|
|
|
- LXC
|
2017-06-14 21:04:16 -04:00
|
|
|
- Parallels
|
|
|
|
- QEMU
|
|
|
|
- VirtualBox
|
|
|
|
- VMware
|
2013-06-27 11:17:00 -04:00
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
-> **Support for additional providers** is planned. If the Vagrant
|
2015-07-22 22:31:00 -04:00
|
|
|
post-processor doesn't support creating boxes for a provider you care about,
|
|
|
|
please help by contributing to Packer and adding support for it.
|
2013-06-27 11:17:00 -04:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
The simplest way to use the post-processor is to just enable it. No
|
2015-07-22 22:31:00 -04:00
|
|
|
configuration is required by default. This will mostly do what you expect and
|
|
|
|
will build functioning boxes for many of the built-in builders of Packer.
|
2013-06-27 11:17:00 -04:00
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
However, if you want to configure things a bit more, the post-processor does
|
|
|
|
expose some configuration options. The available options are listed below, with
|
|
|
|
more details about certain options in following sections.
|
2013-06-27 11:17:00 -04:00
|
|
|
|
2017-10-16 14:23:33 -04:00
|
|
|
- `compression_level` (number) - An integer representing the compression
|
2015-07-22 23:25:58 -04:00
|
|
|
level to use when creating the Vagrant box. Valid values range from 0 to 9,
|
|
|
|
with 0 being no compression and 9 being the best compression. By default,
|
|
|
|
compression is enabled at level 6.
|
2013-12-19 17:10:28 -05:00
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
- `include` (array of strings) - Paths to files to include in the Vagrant box.
|
2015-07-22 23:25:58 -04:00
|
|
|
These files will each be copied into the top level directory of the Vagrant
|
|
|
|
box (regardless of their paths). They can then be used from the Vagrantfile.
|
2013-12-19 17:10:28 -05:00
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
- `keep_input_artifact` (boolean) - If set to true, do not delete the
|
2015-07-22 23:25:58 -04:00
|
|
|
`output_directory` on a successful build. Defaults to false.
|
2014-05-04 13:47:40 -04:00
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
- `output` (string) - The full path to the box file that will be created by
|
2015-07-22 23:25:58 -04:00
|
|
|
this post-processor. This is a [configuration
|
2017-03-28 18:28:34 -04:00
|
|
|
template](/docs/templates/engine.html). The variable
|
2015-07-22 23:25:58 -04:00
|
|
|
`Provider` is replaced by the Vagrant provider the box is for. The variable
|
|
|
|
`ArtifactId` is replaced by the ID of the input artifact. The variable
|
|
|
|
`BuildName` is replaced with the name of the build. By default, the value of
|
|
|
|
this config is `packer_{{.BuildName}}_{{.Provider}}.box`.
|
2013-06-27 11:17:00 -04:00
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
- `vagrantfile_template` (string) - Path to a template to use for the
|
2015-07-22 23:25:58 -04:00
|
|
|
Vagrantfile that is packaged with the box.
|
2013-12-19 17:44:15 -05:00
|
|
|
|
|
|
|
## Provider-Specific Overrides
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
If you have a Packer template with multiple builder types within it, you may
|
|
|
|
want to configure the box creation for each type a little differently. For
|
|
|
|
example, the contents of the Vagrantfile for a Vagrant box for AWS might be
|
|
|
|
different from the contents of the Vagrantfile you want for VMware. The
|
|
|
|
post-processor lets you do this.
|
2013-12-19 17:44:15 -05:00
|
|
|
|
|
|
|
Specify overrides within the `override` configuration by provider name:
|
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
``` json
|
2013-12-19 17:44:15 -05:00
|
|
|
{
|
2014-10-20 13:55:16 -04:00
|
|
|
"type": "vagrant",
|
|
|
|
"compression_level": 1,
|
|
|
|
"override": {
|
|
|
|
"vmware": {
|
|
|
|
"compression_level": 0
|
2013-12-19 17:44:15 -05:00
|
|
|
}
|
2014-10-20 13:55:16 -04:00
|
|
|
}
|
2013-12-19 17:44:15 -05:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
In the example above, the compression level will be set to 1 except for VMware,
|
|
|
|
where it will be set to 0.
|
2013-12-19 17:44:15 -05:00
|
|
|
|
2018-03-06 15:02:19 -05:00
|
|
|
The available provider names are:
|
|
|
|
|
|
|
|
- `aws`
|
|
|
|
- `digitalocean`
|
|
|
|
- `google`
|
|
|
|
- `hyperv`
|
|
|
|
- `parallels`
|
|
|
|
- `libvirt`
|
|
|
|
- `lxc`
|
|
|
|
- `scaleway`
|
|
|
|
- `virtualbox`
|
|
|
|
- `vmware`
|
2014-02-21 17:11:24 -05:00
|
|
|
|
|
|
|
## Input Artifacts
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
By default, Packer will delete the original input artifact, assuming you only
|
|
|
|
want the final Vagrant box as the result. If you wish to keep the input artifact
|
|
|
|
(the raw virtual machine, for example), then you must configure Packer to keep
|
|
|
|
it.
|
2014-02-21 17:11:24 -05:00
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
Please see the [documentation on input
|
|
|
|
artifacts](/docs/templates/post-processors.html#toc_2) for more information.
|