From e95389889089e2eca5bd7598ad53a4be1459f44c Mon Sep 17 00:00:00 2001 From: Steven Lamerton Date: Tue, 6 Jun 2017 16:03:03 +0100 Subject: [PATCH] Add support for salt_bin_dir Allows specifying the path to salt-call, useful if it isn't on the path. --- provisioner/salt-masterless/provisioner.go | 5 ++++- website/source/docs/provisioners/salt-masterless.html.md | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index 9f4dc9b68..b2eefd0ea 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -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) diff --git a/website/source/docs/provisioners/salt-masterless.html.md b/website/source/docs/provisioners/salt-masterless.html.md index fb83fa435..206571e3c 100644 --- a/website/source/docs/provisioners/salt-masterless.html.md +++ b/website/source/docs/provisioners/salt-masterless.html.md @@ -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.