packer build command takes a template and runs all the builds within it
in order to generate a set of artifacts. The various builds specified within a
template are executed in parallel, unless otherwise specified. And the
artifacts that are created will be outputted at the end of the build.
-color=false- Disables colorized output. Enabled by default.
-debug- Disables parallelization and enables debug mode. Debug mode flags the builders that they should output debugging information. The exact behavior of debug mode is left to the builder. In general, builders usually will stop between each step, waiting for keyboard input before continuing. This will allow the user to inspect state and so on.
-except=foo,bar,baz- Run all the builds and post-processors except those with the given comma-separated names. In legacy JSON templates, build names default to the types of their builders (e.g.
virtualbox-iso), unless a specific
nameattribute is specified within the configuration. In HCL2 templates, the "name" is the source block's "name" label, unless an in-build source definition adds the "name" configuration option. Any post-processor following a skipped post-processor will not run. Because post-processors can be nested in arrays a different post-processor chain can still run. A post-processor with an empty name will be ignored.
-force- Forces a builder to run when artifacts from a previous build prevent a build from running. The exact behavior of a forced build is left to the builder. In general, a builder supporting the forced build will remove the artifacts from the previous build. This will allow the user to repeat a build without having to manually clean these artifacts beforehand.
-on-error=run-cleanup-provisioner- Selects what to do when the build fails during provisioning. Please note that this only affects the build during the provisioner run, not during the post-processor run, because it is related to whether or not to keep the instance running and related artifacts like generated SSH keys on the system when a provisioner fails.
cleanupcleans up after the previous steps, deleting temporary files and virtual machines.
abortexits without any cleanup, which might require the next build to use
askpresents a prompt and waits for you to decide to clean up, abort, or retry the failed step.
run-cleanup-provisioneraborts and exits without any cleanup besides the error-cleanup-provisioner if one is defined.
-only=foo,bar,baz- Only run the builds with the given comma-separated names. In legacy JSON templates, build names default to the types of their builders (e.g.
virtualbox-iso), unless a specific
nameattribute is specified within the configuration. In HCL2 templates, the "name" is the source block's "name" label, unless an in-build source definition adds the "name" configuration option.
-parallel-builds=N- Limit the number of builds to run in parallel, 0 means no limit (defaults to 0).
-timestamp-ui- Enable prefixing of each ui output with an RFC3339 timestamp.
-var- Set a variable in your Packer template. This option can be used multiple times. This is useful for setting version numbers for your build.
-var-file- Set template variables from a file.
-warn-on-undeclared-var- Setting this flag will yield a warning for each assignment within a variable definitions file (.pkrvars.hcl | .pkrvars.json) that does not have an accompanying variable block. This can occur when using a var-file that contains a large amount of unused variables for a given HCL2 template. For HCL2 template builds defining a value for a variable in a var-file is not enough on its own for Packer to function, as there also needs to be a variable block definition in the template files
pkr.hclfor the variable. By default
packer buildwill not warn when a var-file contains one or more undeclared variables.