packer-cn/website/source/docs/post-processors/compress.html.markdown

72 lines
2.0 KiB
Markdown
Raw Normal View History

---
2015-07-22 22:31:00 -04: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.
layout: docs
page_title: 'compress Post-Processor'
...
# Compress Post-Processor
Type: `compress`
The Packer compress post-processor takes an artifact with files (such as from
VMware or VirtualBox) and compresses the artifact into a single archive.
## Configuration
### Optional:
2015-06-18 08:13:48 -04: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.
2015-07-22 23:25:58 -04:00
- `output` (string) - The path to save the compressed archive. The archive
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 08:13:48 -04:00
2015-08-04 23:11:53 -04:00
You can use `{{.BuildName}}` and `{{.BuilderType}}` in your output path.
If you are executing multiple builders in parallel you should make sure
`output` is unique for each one. For example `packer_{{.BuildName}}.zip`.
2015-07-22 23:25:58 -04:00
- `compression_level` (integer) - Specify the compression level, for
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 08:13:48 -04:00
2015-07-22 23:25:58 -04:00
- `keep_input_artifact` (boolean) - Keep source files; defaults to `false`
2015-06-18 08:13:48 -04:00
### Supported Formats
2015-07-22 22:31:00 -04: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.
2015-06-18 08:13:48 -04:00
## Examples
2015-07-22 22:31:00 -04:00
Some minimal examples are shown below, showing only the post-processor
configuration:
2015-07-22 22:31:00 -04:00
``` {.json}
{
"type": "compress",
"output": "archive.tar.lz4"
}
```
2015-07-22 22:31:00 -04:00
``` {.json}
{
"type": "compress",
"output": "{{.BuildName}}_bundle.zip"
}
```
2015-07-22 22:31:00 -04:00
``` {.json}
{
"type": "compress",
"output": "log_{{.BuildName}}.gz",
"compression": 9
}
```