2020-03-18 18:46:47 -04:00
|
|
|
---
|
|
|
|
description: |
|
|
|
|
The `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.
|
|
|
|
page_title: packer build - Commands
|
2020-04-02 19:39:47 -04:00
|
|
|
sidebar_title: <tt>build</tt>
|
2020-03-18 18:46:47 -04:00
|
|
|
---
|
|
|
|
|
|
|
|
# `build` Command
|
|
|
|
|
|
|
|
The `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.
|
|
|
|
|
|
|
|
## Options
|
|
|
|
|
|
|
|
- `-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.
|
|
|
|
|
2020-06-23 04:53:16 -04:00
|
|
|
`@include 'commands/except.mdx'`
|
2020-03-18 18:46:47 -04:00
|
|
|
|
|
|
|
- `-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.
|
|
|
|
|
2020-06-16 09:29:56 -04:00
|
|
|
- `-on-error=cleanup` (default), `-on-error=abort`, `-on-error=ask`, `-on-error=run-cleanup-provisioner` -
|
2020-08-10 14:10:37 -04:00
|
|
|
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.
|
2020-07-13 06:33:16 -04:00
|
|
|
|
2020-06-16 09:29:56 -04:00
|
|
|
- `cleanup` cleans up after the previous steps, deleting temporary files and virtual machines.
|
|
|
|
- `abort` exits without any cleanup, which might require the next build to use `-force`.
|
|
|
|
- `ask` presents a prompt and waits for you to decide to clean up, abort, or retry
|
2020-07-13 06:33:16 -04:00
|
|
|
the failed step.
|
2020-06-16 09:29:56 -04:00
|
|
|
- `run-cleanup-provisioner` aborts and exits without any cleanup besides
|
2021-01-27 09:08:59 -05:00
|
|
|
the [error-cleanup-provisioner](/docs/templates/legacy_json_templates/provisioners#on-error-provisioner) if one is defined.
|
2020-03-18 18:46:47 -04:00
|
|
|
|
2020-06-23 04:53:16 -04:00
|
|
|
`@include 'commands/only.mdx'`
|
|
|
|
|
2020-03-18 18:46:47 -04:00
|
|
|
- `-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.
|