Files
Packer-Cn/website/content/docs/commands/init.mdx
T
Adrien Delorme ed091163be HCL2 Parse packer.required_plugins block + packer init (#10304)
This adds the new `required_plugins` block to be nested under the packer block.

Example:
```hcl
packer {
  required_plugins {
    aws = {
      version = ">= 2.7.0"
      source = "azr/aws"
    }
    azure = ">= 2.7.0"
  }
}
```

For example on darwin_amd64 Packer will install those under :
* "${PACKER_HOME_DIR}/plugin/github.com/azr/amazon/packer-plugin-amazon_2.7.0_x5.0_darwin_amd64"
* "${PACKER_HOME_DIR}/plugin/github.com/hashicorp/azure/packer-plugin-azure_2.7.0_x5.0_darwin_amd64_x5"

+ docs
+ tests
2021-02-02 18:05:04 +01:00

63 lines
2.2 KiB
Plaintext

---
description: |
The `packer init` Packer command is used to download Packer plugin binaries.
page_title: packer init - Commands
sidebar_title: <tt>init</tt>
---
# `init` Command
-> **Note:** Packer does not currently have the notion of a state.
-> **Note:** Currently, the plugin getter can only fetch binaries from public
projects on *Github*.
-> **Note:** Currently, the plugin getter only fetches binaries using Github's
public API, which [limits the number of unauthenticated requests per hour one IP
can
do](https://docs.github.com/en/developers/apps/rate-limits-for-github-apps#normal-user-to-server-rate-limits).
Packer will do its best to avoid hitting those limits and in an average local
usage this should not be an issue. Otherwise you can set the
`PKR_GITHUB_API_TOKEN` env var in order to get more requests per hour. Go to
your personal [access token page](https://github.com/settings/tokens) to
generate a new token.
The `packer init` command is used to download Packer plugin binaries.
This is the first command that should be executed when working with a new or
existing template. This command is always safe to run multiple times. Though
subsequent runs may give errors, this command will never delete anything.
`packer init` will list all installed plugins then download the latest versions
for the ones that are missing.
`packer init -upgrade` will try to get the latest versions for all plugins.
Import a plugin using the [`required_plugin`](/docs/templates/hcl_templates/blocks/packer#specifying-plugin-requirements)
block :
```hcl
packer {
required_plugins {
myawesomecloud = {
version = ">= 2.7.0"
source = "azr/myawesomecloud"
}
happycloud = ">= 2.7.0"
}
}
```
Packer init will install the latest found version matching the version selection
in the `required_plugins` section. Make sure to set a correct [version constraint
string](/docs/templates/hcl_templates/blocks/packer#version-constraints).
## Options
- `-upgrade` - On top of installing missing plugins, update installed plugins to
the latest available version, if there is a new higher one. Note that this
still takes into consideration the version constraint of the config.