Add support for salt_bin_dir

Allows specifying the path to salt-call, useful if it isn't on the
path.
This commit is contained in:
Steven Lamerton 2017-06-06 16:03:03 +01:00
parent 07c09fee32
commit e953898890
2 changed files with 7 additions and 1 deletions

View File

@ -61,6 +61,9 @@ type Config struct {
// Arguments to pass to salt-call
SaltCallArgs string `mapstructure:"salt_call_args"`
// Directory containing salt-call
SaltBinDir string `mapstructure:"salt_bin_dir"`
// Command line args passed onto salt-call
CmdArgs string ""
@ -281,7 +284,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
}
ui.Message(fmt.Sprintf("Running: salt-call --local %s", p.config.CmdArgs))
cmd := &packer.RemoteCmd{Command: p.sudo(fmt.Sprintf("salt-call --local %s", p.config.CmdArgs))}
cmd := &packer.RemoteCmd{Command: p.sudo(fmt.Sprintf("%s --local %s", filepath.Join(p.config.SaltBinDir, "salt-call"), p.config.CmdArgs))}
if err = cmd.StartWithUi(comm, ui); err != nil || cmd.ExitStatus != 0 {
if err == nil {
err = fmt.Errorf("Bad exit status: %d", cmd.ExitStatus)

View File

@ -86,3 +86,6 @@ Optional:
[salt-call](https://docs.saltstack.com/ref/cli/salt-call.html) documentation for more
information. By default no additional arguments (besides the ones Packer generates)
are passed to `salt-call`.
- `salt_bin_dir` (string) - Path to the `salt-call` executable. Useful if it is not
on the PATH.