packer

HashiCorp Packer 0.8

We've released Packer 0.8. Packer is a tool for building virtual machine images, containers, and other deployable artifacts.

Packer 0.7 has been out for almost a year (with minor releases since then), and we decided it was time for a major release. Packer 0.8 is an immensely large release, with over a dozen new features. A big thanks to the community who had over 100 pull requests, as well as to HashiCorp employees Chris Bednarski and Clint Shryock who both dedicated time to this release.

Packer 0.8 is available immediately for download and is already running within Atlas.

Feature highlights for Packer 0.8:

»WinRM and Windows Provisioners

Packer now supports WinRM connections as an alternative to SSH. This means that Packer can now natively configure Windows without having to install an SSH server (something that isn't normal for current Windows machines).

WinRM is easy to configure:

{
    "builders": \[{
        ...

        "communicator": "winrm",
        "winrm\_username": "Administrator"
    }\]
}

You can also configure the WinRM port, WinRM password, etc. But most builders will automatically export this information for you.

Packer 0.8 also ships with three new Windows-specific provisioners: PowerShell, windows-shell (cmd), and windows-restart. These provisioners each require WinRM to be used as the connection.

The PowerShell provisioner lets you execute PowerShell scripts, the Windows Shell provisioner executes batch scripts, and the Windows restart provisioner initiates a restart and waits for the machine to complete the restart.

»Windows AWS Images

The Amazon builders for Packer now support creating Windows images. Prior versions of Packer only supported Linux.

Building a Windows AWS image is seamless and requires no new configuration. You only have to specify a Windows AMI as a source image, and Packer will do the rest. You usually want to pair this with the WinRM communicator.

An example valid template to build a Windows AMI is shown below:

{
    "builders": \[{
        "type": "amazon-ebs",
        "region": "us-east-1",
        "source\_ami": "ami-c01102a8",
        "instance\_type": "m3.medium",
        "ami\_name": "windows-ami {{timestamp}}",
        "user\_data\_file": "{{template\_dir}}/setup\_winrm.txt",

        "communicator": "winrm",
        "winrm\_username": "Administrator"
    }\],

    "provisioners": \[
        {
            "type": "powershell",
            "inline": \[
                "dir c:\\\\"
            \]
        }
    \]
}

»SSH Agent Forwarding, Bastion Hosts, and more

SSH within Packer has received many features and improvements. Packer will forward your SSH agent by default, can connect through bastion hosts, and SSH can also be completely disabled now.

SSH agent forwarding requires no new configuration. If Packer detects an SSH agent running on the machine running Packer, it will automatically forward it. You can disable SSH agent forwarding, as well.

Bastion hosts allow Packer to create images within private networks through a bastion. This has been heavily requested for a long time and configuring it is easy:

{
    "builders": \[{
        ...,

        "ssh\_bastion\_host": "1.2.3.4",
        "ssh\_bastion\_username": "foo",
        "ssh\_bastion\_private\_key\_file": "{{template\_dir}}/bastion.key"
    }\],

    "provisioners": \[
        {
            "type": "powershell",
            "inline": \[
                "dir c:\\\\"
            \]
        }
    \]
}

And finally, you can now completely disable SSH if you don't want to use it. You can do this by specifying "communicator": "none". Note that without a communicator, provisioners will not work.

»OpenStack Identity v3 and more

The OpenStack builder has been reworked from the ground up to be much more user friendly and to support new features. The most notable new feature is support for v3 of the identity API.

In addition to identity v3, various improvements have been made:

  • UUID as well as human friendly names can be specified for flavors and images.

  • Availability zones are supported.

  • Packer will stop the instance prior to snapshotting to avoid disk corruption if the OpenStack cluster supports the extension.

  • User data is supported.

And much more...

»Local Shell Provisioning

Packer now has a shell-local provisioner for executing local shell scripts as part of the provisioning process. Usage is straightforward:

{
    "provisioners": \[{
         "type": "shell-local",
         "command": "echo hello!"
    }\]
}

This is also supported in Atlas! Atlas runs Packer builds within a virtual machine, so you can execute custom scripts.

»Dozens of smaller improvements

In addition to the major features above, Packer 0.8 includes some noteworthy improvements:

  • The file provisioner supports downloading files from the remote machine.

  • The compress post-processor supports multiple compression algorithms and will also compress files in parallel if possible.

  • Downloads of ISOs and other large files now support resuming. If you ctrl-C or Packer crashes, the download will resume on the next run.

  • Every builder now supports all SSH options, WinRM, etc. Before, each builder had different SSH options.

  • The Docker builder supports containers with SSH.

  • New configuration functions are available: build_name, build_type, and template_dir.

»Conclusion

Packer 0.8 is a huge release with many features. The highlight of the release is the improvement in Windows support across the board. Packer can now build Windows images for any builder that supports it without any external plugins. Features such as resumable file downloads also help Windows, which generally has very large ISOs.

But in addition to Windows, Packer 0.8 improved almost every builder across the board. OpenStack was rewritten, all outstanding Amazon builder bugs are fixed, the DigitalOcean builder is much more stable, etc.

Download Packer now or use it in Atlas.


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.