provisioner/salt: pass args to bootstrap
This commit is contained in:
parent
361d7fbf8e
commit
a74a515aa7
|
@ -16,8 +16,9 @@ import (
|
||||||
var Ui packer.Ui
|
var Ui packer.Ui
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
// If true, skips installing Salt. Defaults to false.
|
// If true, run the salt-bootstrap script
|
||||||
SkipInstall bool `mapstructure:"skip_install"`
|
SkipBootstrap bool `mapstructure:"skip_bootstrap"`
|
||||||
|
BootstrapArgs string `mapstructure:"bootstrap_args"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Provisioner struct {
|
type Provisioner struct {
|
||||||
|
@ -64,26 +65,17 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func InstallSalt(comm packer.Communicator) (err error) {
|
|
||||||
Ui.Say("Installing Salt")
|
|
||||||
cmd := "wget -O - http://bootstrap.saltstack.org | sudo sh"
|
|
||||||
if err = executeCommand(cmd, comm); err != nil {
|
|
||||||
return fmt.Errorf("Unable to install Salt: %d", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||||
var err error
|
var err error
|
||||||
Ui = ui
|
Ui = ui
|
||||||
|
|
||||||
if !p.config.SkipInstall {
|
if !p.config.SkipBootstrap {
|
||||||
if err = InstallSalt(comm); err != nil {
|
cmd := fmt.Sprintf("wget -O - http://bootstrap.saltstack.org | sudo sh -s %s", p.config.BootstrapArgs)
|
||||||
return fmt.Errorf("Error installing Salt: %s", err)
|
Ui.Say(fmt.Sprintf("Installing Salt with command %s", cmd))
|
||||||
|
if err = executeCommand(cmd, comm); err != nil {
|
||||||
|
return fmt.Errorf("Unable to install Salt: %d", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue