github.com/hashicorp/packer@v1.14.3/website/content/docs/plugins/install.mdx (about)

     1  ---
     2  description: |
     3    You can install plugins to extend Packer functionality. Learn how to install external plugins.
     4  page_title: Install Plugins
     5  ---
     6  
     7  # Install Plugins
     8  
     9  <Note>
    10  
    11  Starting August 1st, 2025, the source for many official HashiCorp-maintained Packer plugins is moving from GitHub releases to the official HashiCorp release site, [releases.hashicorp.com](https://releases.hashicorp.com). Refer to [Install HashiCorp-maintained plugins](#install-hashicorp-maintained-plugins) for more information.
    12  
    13  </Note>
    14  
    15  This topic describes how to install external plugins for Packer. Refer to [Packer Plugins Overview](/packer/docs/plugins) for additional information about plugins.
    16  
    17  ## Overview
    18  
    19  Specify one or more required plugins in a Packer template and run the initialization command. During initialization, Packer queries the source repository for plugins specified in the template that match the version constraints for the host operating system. Packer downloads and installs plugins and other dependencies specified in the template.
    20  
    21  You can specify a remote project on GitHub for Packer to install the plugin from. Refer to [Requirements](#requirements) for additional information about installing plugins from a remote source.
    22  
    23  When you run the Packer template, Packer first checks the directory for installed plugins that match the version requirements specified in the template. If a suitable version of the plugin is not installed, Packer prints an error. Packer downloads the required version from the `source` configuration.
    24  
    25  ### Manual installation method
    26  
    27  You can manually install plugins if you are unable to specify plugins in an HCL template file. You may need to use the manual plugin installation method if the plugin source is a non-GitHub project or if your plugins are still in development.
    28  
    29  Manually install a plugin using the `packer plugins install` command. You specify a local or remote plugin source and include a path to the binary to generate the SHA256SUM file required to load the plugin during Packer builds. Refer to [Requirements](#requirements) for additional information about installing plugins from a remote source.
    30  
    31  Note that Packer checks the plugin installation directory against the `required_plugins` block in the Packer template when you build artifacts using the template. Plugins specified in the template that have been installed manually must still comply with the version constraints set in the template.
    32  
    33  
    34  ### Installation directory
    35  
    36  By default, Packer installs plugins into the plugins directory at `$HOME/.config/packer/plugins` on Unix and  `%APPDATA%\packer.d\plugins` on Windows, but you can specify a different directory using the `PACKER_PLUGIN_PATH` environment variable.
    37  
    38  <Note>
    39  
    40  Plugin installation requires access to temporary files under `TMPDIR`. If the system's temp directory is non-writable or non-executable, use TMPDIR to override the location of the temporary file store used by Packer.
    41  Refer to the [Packer configuration reference](/packer/docs/configure) for additional information.
    42  
    43  </Note>
    44  
    45  ## Requirements
    46  
    47  To install a plugin from a remote source, the plugin must meet the following requirements:
    48  
    49  - The plugin project must be hosted on GitHub.
    50  - The repository must be named `packer-plugin-<name>`.
    51  - The project must have semantic version tags per the following format: `v<major>.<minor>.<patch>`.
    52  - The release linked to the tag must be available with a `shasums` file that indicates which files are available in the release.
    53  
    54  ### GitHub API token
    55  
    56  GitHub's public API limits the number of unauthenticated requests per hour from a single IP address. Refer to the [GitHub rate limits documentation](https://docs.github.com/en/developers/apps/rate-limits-for-github-apps#normal-user-to-server-rate-limits) for additional information.
    57  
    58  If you expect to exceed the request rate limit, you can use a GitHub API token to authenticate requests and exceed the rate limit. We recommend setting a GitHub API token when running Packer from a continuous integration server to avoid potential rate limiting errors. Refer to [Authenticate requests to the GitHub API](#authenticate-requests-to-the-github-api) for instructions.
    59  
    60  ## Install a plugin
    61  
    62  1. In your Packer template file, add the `required_plugins` block to the `packer` block.
    63  1. Specify the name of the plugin and its `version` and `source` parameters. Setting a correct [version constraint string](/packer/docs/templates/hcl_templates/blocks/packer#version-constraints) is important for
    64  pinning plugin versions for build reproducibility. Refer to the [`packer` block configuration reference](/packer/docs/templates/hcl_templates/blocks/packer) for additional information.
    65  
    66     The following example configures Packer to install a plugin called `happycloud`. When the template is initialized, Packer downloads version 2.7.0 or newer of the plugin from GitHub:
    67  
    68      ```hcl
    69      packer {
    70        required_plugins {
    71          happycloud = {
    72            version = ">= 2.7.0"
    73            source = "github.com/hashicorp/happycloud"
    74          }
    75        }
    76      }
    77  
    78      ```
    79  
    80  1. Run the `packer init` command. Packer lists all installed plugins then installs the latest plugin version matching the version constraints specified in the `required_plugins` block. Refer to the [`init` command reference](/packer/docs/commands/init) for additional information.
    81  
    82  ## Install HashiCorp-maintained plugins
    83  
    84  HashiCorp now makes the following official HashiCorp-maintained plugins available through the [HashiCorp release site](https://releases.hashicorp.com/). 
    85  
    86  These plugins include:
    87  
    88  - [Amazon](https://developer.hashicorp.com/packer/integrations/hashicorp/amazon)
    89  - [Ansible](https://developer.hashicorp.com/packer/integrations/hashicorp/ansible)
    90  - [Azure](https://developer.hashicorp.com/packer/integrations/hashicorp/azure)
    91  - [Docker](https://developer.hashicorp.com/packer/integrations/hashicorp/docker)
    92  - [Google Cloud Platform](https://developer.hashicorp.com/packer/integrations/hashicorp/googlecompute)
    93  - [QEMU](https://developer.hashicorp.com/packer/integrations/hashicorp/qemu)
    94  - [Vagrant](https://developer.hashicorp.com/packer/integrations/hashicorp/vagrant)
    95  - [VirtualBox](https://developer.hashicorp.com/packer/integrations/hashicorp/virtualbox)
    96  
    97  Starting in Packer 1.14.0, Packer automatically installs these plugins from the new release source, and you do not need to make any changes to your Packer templates. To continue to automatically receive updates to these plugins, you must upgrade to Packer 1.14.0 or newer. If you cannot upgrade your version of Packer, you can still install new versions of these plugins manually. Refer to [Manually install plugins using the CLI](#manually-install-plugins-using-the-cli) for more information.
    98  
    99  ## Manually install plugins using the CLI
   100  
   101  You can use the `packer plugins install` command to manually install plugin binaries.
   102  Use the `--path` flag to specify a local source. Packer then automatically calculates the SHA256SUM file and installs the files into the Packer plugin directory:
   103  
   104  ```shell-session
   105  $ packer plugins install --path <path-to-downloaded-extracted-binary> <hostname>/<namespace>/<plugin-name>
   106  ```
   107  
   108  The following example installs the `happycloud` plugin from a locally-sourced binary:
   109  
   110  ```shell-session
   111  $ unzip packer-plugin-happycloud.zip
   112  $ ls -l
   113  -rwxr-xr-x [...] happycloud
   114  $ packer plugins install --path happycloud github.com/hashicorp/happycloud
   115  ```
   116  
   117  Refer to the [`packer plugins install`](/packer/docs/commands/plugins/install) reference for additional information.
   118  
   119  ## Upgrade plugins
   120  
   121  To upgrade plugins that are already installed, run the `packer init` with the `--upgrade` flag. Packer retrieves the latest versions of installed plugins specified in the template configuration.
   122  
   123  The following example upgrades plugins according to the template in the current directory:
   124  
   125  ```shell-session
   126  $ packer init --upgrade .
   127  ```
   128  
   129  Refer to [`packer init` command](/packer/docs/commands/init) for additional information.
   130  
   131  ## Use a plugin under development
   132  
   133  If a development binary, such as a manually-built binary, is available at the specified source, Packer uses it in the build if it is the highest compatible version installed and if no final plugin version with the same version number is installed alongside it.
   134  
   135  In the following example, version `1.1.0` or newer is required:
   136  
   137  ```hcl
   138  packer = {
   139      required_plugins = {
   140          amazon = {
   141              source = "github.com/hashicorp/amazon"
   142              version = ">= 1.1.0"
   143          }
   144      }
   145  
   146  . . .
   147  
   148  }
   149  ```
   150  
   151  Packer uses the `-dev` version of the Amazon plugin if the following binaries are available:
   152  
   153  ```shell-session
   154  /Users/dev/.packer.d/plugins
   155  └─ github.com
   156     └─ hashicorp
   157      	└── amazon
   158            ├── packer-plugin-amazon_v1.1.0_x5.0_darwin_arm64
   159            ├── packer-plugin-amazon_v1.1.0_x5.0_darwin_arm64_SHA256SUM
   160            ├── packer-plugin-amazon_v1.1.1-dev_x5.0_darwin_arm64
   161            └── packer-plugin-amazon_v1.1.1-dev_x5.0_darwin_arm64_SHA256SUM
   162  ```
   163  
   164  When a non-development version of 1.1.1 becomes available, the binary takes precedence over the development binary:
   165  
   166  ```shell-session
   167  /Users/dev/.packer.d/plugins
   168  └─ github.com
   169     └─ hashicorp
   170      	└── amazon
   171            ├── packer-plugin-amazon_v1.1.1-dev_x5.0_darwin_arm64
   172            ├── packer-plugin-amazon_v1.1.1-dev_x5.0_darwin_arm64_SHA256SUM
   173            ├── packer-plugin-amazon_v1.1.1_x5.0_darwin_arm64
   174            └── packer-plugin-amazon_v1.1.1_x5.0_darwin_arm64_SHA256SUM
   175  ```
   176  
   177  ### Example Docker plugin
   178  
   179  Complete the following steps to build and install a custom version of the Docker plugin as an example:
   180  
   181  1. Clone the plugin's GitHub repository.
   182  
   183      ```shell-session
   184      $ git clone https://github.com/hashicorp/packer-plugin-docker.git
   185      ```
   186  
   187  1. Change to the plugin directory root and run the `go build` command to build the plugin as a development binary.
   188  
   189      ```shell-session
   190      $ cd packer-plugin-docker
   191      $ go build -ldflags="-X github.com/hashicorp/packer-plugin-docker/version.VersionPrerelease=dev" -o packer-plugin-docker-dev
   192      ```
   193  
   194  1. Validate the release version.
   195  
   196      ```shell-session
   197      $ ./packer-plugin-docker-dev describe
   198      {"version":"1.0.10-dev","sdk_version":"0.5.2","api_version":"x5.0","builders":["-packer-default-plugin-name-"],"post_processors":["import","push","save","tag"],"provisioners":[],"datasources":[]}
   199      ```
   200  
   201  1. Use the `packer plugins install` command to install the development binary.
   202  
   203      ```shell-session
   204      packer plugins install --path packer-plugin-docker-dev github.com/hashicorp/docker
   205      Successfully installed plugin github.com/hashicorp/docker from $HOME/Development/packer-plugin-docker/packer-plugin-docker-dev to ~/github.com/hashicorp/docker/packer-plugin-docker_v1.0.10-dev_x5.0_darwin_arm64
   206      ```
   207  
   208  1. Run a `packer build` with the newly installed plugin.
   209  
   210      ```shell-session
   211      $ packer build .
   212      ```
   213  
   214  For convenience, the makefile in the Packer plugin scaffolding repository builds and installs development binaries using `make dev`.
   215  
   216  Refer to the documentation in the [Packer plugin scaffolding repository](https://github.com/hashicorp/packer-plugin-scaffolding?tab=readme-ov-file#build-from-source) for additional information.
   217  
   218  ## Authenticate requests to the GitHub API
   219  
   220  You can set the `PACKER_GITHUB_API_TOKEN` environment variable to send more requests per hour than the limits imposed by the GitHub API:
   221  
   222  1. Go to your personal [access token page](https://github.com/settings/tokens) to
   223  generate a new token.
   224  1. Set the `PACKER_GITHUB_API_TOKEN` environment variable to your token value:
   225  
   226      ```shell-session
   227      $ export PACKER_GITHUB_API_TOKEN=<token>
   228      ```