This post-processor for Packer creates a tarball of the root filesystem using Guestfish. The resulting image is suitable for deploying OpenVZ containers.
The Qemu builder is used in favor of a writing a separate OpenVZ builder for a few reasons:
- Preference building from an ISO over an existing template
- Qemu does not require a proprietary kernel
- The Qemu builder is stable, and writing post-processors is relatively easy
- Having a tarball of the filesystem potentially has uses outside of OpenVZ
- Packer 0.8.x+
- Guestfish (and libguestfs)
- Qemu (preferrably with KVM acceleration)
First, download and install the plugin:
$ go get github.com/DavidWittman/packer-post-processor-tarballThen, move the binary from $GOPATH/bin/packer-post-processor-tarball to one of three locations:
- The directory where packer is, or the executable directory
~/.packer.d/plugins/(Unix) or%APPDATA%/packer.d/plugins(Windows)- The current working directory
Once the packer-post-processor-tarball binary is in a directory which is discoverable by Packer, you can add this post-processor to your template as follows:
{
"post-processors": ["tarball"]
}Here are all of the available configuration options (and their defaults) for this post-processor. Keys beginning with an underscore are comments.
{
"post-processors": [
{
"type": "tarball",
"_comment": "The directory to write artifacts to",
"output": "packer_{{.BuildName}}_tarball",
"_comment": "Filename to use for the artifact. `tarball_extension` will be appended to the end",
"tarball_filename": "packer_{{.BuildName}}",
"_comment": "Filename extension to use",
"tarball_extension": ".tar.gz",
"_comment": "Compression type. E.g. `gzip`, `xz`, `bzip2`. See tar-out in guestfish(1) for all supported types.",
"compression": "gzip",
"_comment": "The Guestfish binary to use",
"guestfish_binary": "guestfish",
"_comment": "How long (in seconds) to wait for Guestfish to mount the file system",
"guestfish_mount_timeout": 10,
"_comment": "Keep the input artifact which was received by this post-processor",
"keep_input_artifact": false
}
]
}See the Packer templates at DavidWittman/packer-openvz-templates.