Skip to main content

Announcing Packer v.1.4.0

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.

»Docker for Windows

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
    }
  ]
}

»Recursive User Variable Interpolation

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.

»Provisioner Timeout and Sleep Provisioner

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"
}

»Other Miscellaneous Goodies

  • We've added an option to the shell and windows-shell provisioner to allow users to specify "passing" non-zero exit codes
  • We've updated Packer to avoid VNC port collisions when running multiple builds in parallel which specify the same port range.
  • For our windows + ansible users, you may be interested in a documentation update provided by one of our community members which may address issues you've been facing with the WinRM ansible plugin. [GH-7461]
  • Packer is now using hashicorp/go-getter to download files. The getter brings features, common wisdom and safety from other hashicorp projects.
  • Shell communicator now forwards Stderr logs to the error output.
  • Packer now uses a tty to receive user inputs.

»Backwards Incompatibilities

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.

»Other Packer Highlights

In case you missed them, here are some release highlights from this year so far:

»New Builders, Provisioners, and Post-processors

»Miscellaneous

  • Vault + AWS integration in Packer Template
  • Post-processors now respect the "except" command line flag.
  • Builder, Provisioner, Hook & PostProcessor type are now context cancelled, this change broke their API and plugins will need to be updated.

Sign up for the latest HashiCorp news

By submitting this form, you acknowledge and agree that HashiCorp will process your personal information in accordance with the Privacy Policy.