add docs for error provisioner

This commit is contained in:
Megan Marsh 2019-10-01 11:08:15 -07:00
parent b69797f156
commit 5be06912a7
1 changed files with 36 additions and 0 deletions

View File

@ -83,6 +83,42 @@ specify a custom `name` parameter, then you should use that as the value
instead of the type.
Values within `except` could also be a *post-processor* name.
## On Error Provisioner
You can optionally create a single specialized provisioner field called an
`error-cleanup-provisioner`. This provisioner will not run unless the normal
provisioning run fails. If the normal provisioning run does fail, this special
error provisioner will run *before the instanace is shut down*. This allows you
to make last minute changes and clean up behaviors that Packer may not be able
to clean up on its own.
For examples, users may use this provisioner to make sure that the instance is
properly unsubscribed from any services that it connected to during the build
run.
Toy usage example for the error cleanup script:
```json
{
"builders": [
{
"type": "null",
"communicator": "none"
}
],
"provisioners": [
{
"type": "shell-local",
"inline": ["exit 2"]
}
],
"error-cleanup-provisioner": {
"type": "shell-local",
"inline": ["echo 'rubber ducky'> ducky.txt"]
}
}
```
## Build-Specific Overrides
While the goal of Packer is to produce identical machine images, it sometimes