We are excited to share Packer v.1.4.0 with the community. This blog post will go into the new features coming with this release.
We've added beta-level support for our Docker builder to be used in conjunction with Windows containers.
If you are building a Windows container, you'll have to either click "Switch to Windows containers" in the Docker tray menu or run the following command in powershell:
& $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon .
You must also set the Packer template option "windows_container": true
. Please note that docker cannot export Windows containers, so you must either commit or discard them.
The following is a fully functional template for building a Windows container via the Docker builder.
{
"builders": [
{
"type": "docker",
"image": "microsoft/windowsservercore:1709",
"container_dir": "c:/app",
"windows_container": true,
"commit": true
}
]
}
Another template-level improvement we've made is that you can now reference user variables set in the variables section of the packer template, within that section. You can use this to define variables that depend on other variables. For example, the following fully-functional sample packer template demonstrates how you can set one variable via another.
{
"variables": {
"baz": "{{user `foo`}}baz",
"foo": "whee",
"bang": "bang{{user `baz`}}"
},
"builders": [{
"type": "null",
"communicator": "none"
}],
"provisioners": [{
"type": "shell-local",
"environment_vars": ["FOO={{ user `foo` }}",
"BAZ={{ user `baz` }}",
"BANG={{ user `bang` }}"],
"inline": ["echo $FOO",
"echo $BAZ",
"echo $BANG"]
}]
}
Expected output:
null: whee
null: wheebaz
null: bangwheebaz
If you try to reference a user variable that has not been set or is an empty string, Packer will error.
The new sleep provisioner will sleep during the duration
setting. All provisioner now get a timeout
parameter that will cancel a privioner after a timeout
duration. The following provisioner will timeout after sleeping for 1 second:
{
"type": "sleep",
"duration": "2m",
"timeout": "1s"
}
There are a handful of backwards incompatible changes to naming within the template, most of which we've done to improve coherence across or within builders. These can all be fixed by using a fixer. Call "packer fix yourtemplate.json" and we'll spit out a template that uses the appropriate option names.
All backwards-incompatible changes for this release and their associated github issues can be found in our changelog.
In case you missed them, here are some release highlights from this year so far:
As the final step in moving towards external plugins, HashiCorp Packer will stop bundling official plugins within its binary releases. Here’s what that means.
Learn how creating a golden image pipeline can help unify and streamline your imaging and provisioning workflows throughout your infrastructure estate.
The Packer Azure plugin has migrated to the HashiCorp Go Azure SDK to address known Azure SDK deprecations and provide a consistent foundation for managing Azure infrastructure.