Controlling flow and using breakpoints
We may also need Packer to pause before continuing part of a build. Remember—by default, an error will cause Packer to destroy the environment, which unfortunately makes it hard for troubleshooting what went wrong. Rather than debugging through a build step by step, we can do some basic options to have Packer stop where we want it to.
First and foremost is the -on-error
option. This can have one of four values. By default, it is set to cleanup
, which explains why Packer deletes the build environment after errors. Again, as per the Packer documents, it may be helpful to set it to one of the following instead:
abort
: Exits without cleanup.ask
: Prompts and waits for you to decide to clean up, abort, or retry the failed step.cleanup (default)
: Exits with cleanup. This is the default.run-cleanup-provisioner
: Aborts with theerror-cleanup-provisioner
if one is defined.
If running Packer interactively, the ask
...