2014-09-08 10:30:10 -07:00
|
|
|
---
|
2017-06-14 18:04:16 -07:00
|
|
|
description: |
|
|
|
|
The Packer compress post-processor takes an artifact with files (such as from
|
|
|
|
VMware or VirtualBox) and compresses the artifact into a single archive.
|
2015-07-22 19:31:00 -07:00
|
|
|
layout: docs
|
2017-06-14 18:04:16 -07:00
|
|
|
page_title: 'Compress - Post-Processors'
|
|
|
|
sidebar_current: 'docs-post-processors-compress'
|
2017-03-25 18:13:52 -04:00
|
|
|
---
|
2014-09-08 10:30:10 -07:00
|
|
|
|
|
|
|
# Compress Post-Processor
|
|
|
|
|
|
|
|
Type: `compress`
|
|
|
|
|
2014-10-20 16:47:30 -04:00
|
|
|
The Packer compress post-processor takes an artifact with files (such as from
|
2015-06-18 03:55:51 -07:00
|
|
|
VMware or VirtualBox) and compresses the artifact into a single archive.
|
2014-09-08 10:30:10 -07:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2015-08-04 19:46:14 -07:00
|
|
|
### Optional:
|
2015-06-18 05:13:48 -07:00
|
|
|
|
2015-08-04 19:46:14 -07:00
|
|
|
By default, packer will build archives in `.tar.gz` format with the following
|
|
|
|
filename: `packer_{{.BuildName}}_{{.BuilderType}}`. If you want to change this
|
|
|
|
you will need to specify the `output` option.
|
2014-09-08 10:30:10 -07:00
|
|
|
|
2017-06-14 18:04:16 -07:00
|
|
|
- `output` (string) - The path to save the compressed archive. The archive
|
2018-10-26 17:02:51 -07:00
|
|
|
format is inferred from the filename. E.g. `.tar.gz` will be a gzipped
|
|
|
|
tarball. `.zip` will be a zip file. If the extension can't be detected
|
|
|
|
packer defaults to `.tar.gz` behavior but will not change the filename.
|
2015-06-18 05:13:48 -07:00
|
|
|
|
2015-08-10 10:25:19 -07:00
|
|
|
You can use `{{.BuildName}}` and `{{.BuilderType}}` in your output path. If
|
|
|
|
you are executing multiple builders in parallel you should make sure
|
2015-08-04 19:46:14 -07:00
|
|
|
`output` is unique for each one. For example `packer_{{.BuildName}}.zip`.
|
2015-06-18 00:47:33 -07:00
|
|
|
|
2017-06-14 18:04:16 -07:00
|
|
|
- `format` (string) - Disable archive format autodetection and use provided
|
2016-05-08 14:11:54 +03:00
|
|
|
string.
|
|
|
|
|
2017-10-16 11:23:33 -07:00
|
|
|
- `compression_level` (number) - Specify the compression level, for
|
2015-07-22 20:25:58 -07:00
|
|
|
algorithms that support it, from 1 through 9 inclusive. Typically higher
|
|
|
|
compression levels take longer but produce smaller files. Defaults to `6`
|
2015-06-18 05:13:48 -07:00
|
|
|
|
2019-04-03 13:57:22 -07:00
|
|
|
- `keep_input_artifact` (boolean) - if `true`, keep both the source files and
|
|
|
|
the compressed file; if `false`, discard the source files. Defaults to
|
|
|
|
`false`
|
2015-06-18 00:47:33 -07:00
|
|
|
|
2015-06-18 05:13:48 -07:00
|
|
|
### Supported Formats
|
2015-06-18 00:47:33 -07:00
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
Supported file extensions include `.zip`, `.tar`, `.gz`, `.tar.gz`, `.lz4` and
|
|
|
|
`.tar.lz4`. Note that `.gz` and `.lz4` will fail if you have multiple files to
|
|
|
|
compress.
|
2014-09-08 10:30:10 -07:00
|
|
|
|
2015-06-18 05:13:48 -07:00
|
|
|
## Examples
|
2014-09-08 10:30:10 -07:00
|
|
|
|
2015-07-22 19:31:00 -07:00
|
|
|
Some minimal examples are shown below, showing only the post-processor
|
|
|
|
configuration:
|
2015-06-18 00:47:33 -07:00
|
|
|
|
2017-06-14 18:04:16 -07:00
|
|
|
``` json
|
2015-06-18 00:47:33 -07:00
|
|
|
{
|
|
|
|
"type": "compress",
|
2015-06-18 03:55:51 -07:00
|
|
|
"output": "archive.tar.lz4"
|
2015-06-18 00:47:33 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-06-14 18:04:16 -07:00
|
|
|
``` json
|
2015-06-18 00:47:33 -07:00
|
|
|
{
|
|
|
|
"type": "compress",
|
2015-08-04 19:46:14 -07:00
|
|
|
"output": "{{.BuildName}}_bundle.zip"
|
2015-06-18 00:47:33 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-06-14 18:04:16 -07:00
|
|
|
``` json
|
2014-09-08 10:30:10 -07:00
|
|
|
{
|
|
|
|
"type": "compress",
|
2015-08-04 19:46:14 -07:00
|
|
|
"output": "log_{{.BuildName}}.gz",
|
2015-09-30 20:40:58 -05:00
|
|
|
"compression_level": 9
|
2014-09-08 10:30:10 -07:00
|
|
|
}
|
2014-10-20 13:55:16 -04:00
|
|
|
```
|