provisioner/salt: pass args to bootstrap

This commit is contained in:
Rafael Garcia 2013-07-26 14:14:41 -07:00
parent 361d7fbf8e
commit a74a515aa7
1 changed files with 8 additions and 16 deletions

View File

@ -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
} }