Skip to main content

Packer Plugins

Packer plugins are separate, standalone applications that perform tasks during each build.

During a packer build, the process list shows packer- prefix applications. One of these applications is the Packer binary and the rest are plugins. Packer starts a plugin process for each component in the build.

Plugins have different levels

LevelDescriptionNamespace
OfficialOfficial plugins are owned and maintained by HashiCorp.hashicorp
VerifiedVerified plugins are owned and maintained by third-party technology partners, but verified by HashiCorpThird-party organization
CommunityProvided by the community.
ArchivedNo longer maintained by HashiCorp, a partner or the community.hashicorp or third-party

The Packer binary has a set of built-in plugins that can be found and run automatically. You can also define a list of external plugins in your template for Packer to run and communicate with during the build. These external plugins extend Packer's functionality without modifying the core source code.

These plugins must be defined within the packer block. That's why I like to separate in packer.pkr.hcl.

Check the list of external plugins

The most important ones:

  • Ansible (Official)
  • Amazon EC2 (Official)
  • Azure (Official)
  • Git

In our study we will use the amazon and azure plugin. It is necessary to define them within the packer block, but I like to separate this block in the packer.pkr.hcl file.

packer {
required_version = ">= 1.8.5"
required_plugins {
amazon = {
version = ">= 1.2.1"
source = "github.com/hashicorp/amazon"
}
azure = {
version = ">= 1.4.1"
source = "github.com/hashicorp/azure"
}
}
}

The packer init . command will download these plugins. These plugins by default are saved in ~/.config/packer/plugins and not in the project as terraform does with .terraform. Once the plugin is downloaded in the correct version, other executions will not download it again if the version is compatible.

~/.config/packer                                                                                                 1.3.7 02:06:06
❯ tree
.
β”œβ”€β”€ checkpoint_cache
β”œβ”€β”€ checkpoint_signature
└── plugins
└── github.com
└── hashicorp
β”œβ”€β”€ amazon
β”‚ β”œβ”€β”€ packer-plugin-amazon_v1.2.1_x5.0_linux_amd64
β”‚ └── packer-plugin-amazon_v1.2.1_x5.0_linux_amd64_SHA256SUM
└── azure
β”œβ”€β”€ packer-plugin-azure_v1.4.1_x5.0_linux_amd64
└── packer-plugin-azure_v1.4.1_x5.0_linux_amd64_SHA256SUM