From f7cf9ede1939381eb60c0c2a7c696b684112d5ba Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Wed, 12 Jun 2024 23:35:16 -0400 Subject: [PATCH] docs: update init Adds additional examples and help regarding the use of `packer init`. Ref: #11541 Signed-off-by: Ryan Johnson --- website/content/docs/commands/init.mdx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/website/content/docs/commands/init.mdx b/website/content/docs/commands/init.mdx index 99b734ca991..778c0760090 100644 --- a/website/content/docs/commands/init.mdx +++ b/website/content/docs/commands/init.mdx @@ -25,29 +25,49 @@ We recommend that you vet and verify any third-party plugins you want to install 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. Refer to the [Packer configuration reference](/packer/docs/configure) for additional information. ## Usage + Use the following syntax to run the `packer init` command: ```shell-session -$ packer init +$ packer init ``` +The command will process any template file that ends with `pkr.hcl`. The template must contain all dependencies when running the command on a single template file. The command fails if the template is intended to be built as a bundle of partials. +For variable definitions, it is recommended to use the extensions `.pkrvars.hcl` or `.auto.pkrvars.hcl`. When you run `packer init` in the directory, these variable definition files will be automatically excluded from processing. + ## Examples -The following example installs the plugins specified in a template named `template.pkr.hcl`: +The following example installs the plugins specified in a template from the current directory: +```shell-session +$ packer init . +``` + +The following example installs the plugins specified in a template named `template.pkr.hcl` from the current directory: ```shell-session $ packer init template.pkr.hcl ``` +The following example installs the plugins specified in the `builds/foo/` directory: + +```shell-session +$ packer init builds/foo/. +``` + +The following example installs the plugins specified in a template from the `builds/foo/template.pkr.hcl` path: + +```shell-session +$ packer init builds/foo/template.pkr.hcl +``` + ## Arguments You can pass the following arguments: - Packer template: Specify the path to either an HCL2 template or a directory containing at least one valid HCL2 template and related dependencies. - ## Options - `-upgrade`: Use this option to upgrade plugins that are already installed to the latest available version. Packer upgrades to the latest version in accordance with the version constraints specified in the template.