Merge pull request #7948 from DanHam/shell-local-fixes

Fix incorrect `execute_command` defaults in shell-local post-processor docs
This commit is contained in:
Megan Marsh 2019-08-12 12:59:06 -07:00 committed by GitHub
commit d78c8040a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 13 deletions

View File

@ -47,7 +47,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
}
// Force shell-local pp to keep the input artifact, because otherwise we'll
// lose it instead of being able to pass it through. If oyu want to delete
// lose it instead of being able to pass it through. If you want to delete
// the input artifact for a shell local pp, use the artifice pp to create a
// new artifact
return artifact, true, true, retErr

View File

@ -68,18 +68,29 @@ Optional parameters:
it is necessary below.
- `execute_command` (array of strings) - The command used to execute the
script. By default this is `["/bin/sh", "-c", "{{.Vars}}", "{{.Script}}"]`
on unix and `["cmd", "/c", "{{.Vars}}", "{{.Script}}"]` on windows. This is
treated as a [template engine](/docs/templates/engine.html). There are two
available variables: `Script`, which is the path to the script to run, and
`Vars`, which is the list of `environment_vars`, if configured. If you
choose to set this option, make sure that the first element in the array is
the shell program you want to use (for example, "sh" or
"/usr/local/bin/zsh" or even "powershell.exe" although anything other than
a flavor of the shell command language is not explicitly supported and may
be broken by assumptions made within Packer). It's worth noting that if you
choose to try to use shell-local for Powershell or other Windows commands,
the environment variables will not be set properly for your environment.
script. By default, on *nix systems this is:
```
["/bin/sh", "-c", "{{.Vars}} {{.Script}}"]
```
While on Windows, `execute_command` defaults to:
```
["cmd", "/V", "/C", "{{.Vars}}", "call", "{{.Script}}"]
```
This is treated as a [template engine](/docs/templates/engine.html).
There are two available variables: `Script`, which is the path to the
script to run, and `Vars`, which is the list of `environment_vars`, if
configured. If you choose to set this option, make sure that the first
element in the array is the shell program you want to use (for example,
"sh" or "/usr/local/bin/zsh" or even "powershell.exe" although anything
other than a flavor of the shell command language is not explicitly
supported and may be broken by assumptions made within Packer). It's
worth noting that if you choose to try to use shell-local for
Powershell or other Windows commands, the environment variables will
not be set properly for your environment.
For backwards compatibility, `execute_command` will accept a string instead
of an array of strings. If a single string or an array of strings with only