added parameter for setting packer password as env variable

This commit is contained in:
Levi
2018-07-14 11:25:00 -04:00
parent 1b967e60f9
commit 37fd50995f
+5
View File
@@ -57,6 +57,7 @@ type Config struct {
UseSFTP bool `mapstructure:"use_sftp"`
InventoryDirectory string `mapstructure:"inventory_directory"`
InventoryFile string `mapstructure:"inventory_file"`
SetPackerPasswd bool `mapstructure:"set_packer_passwd"`
}
type Provisioner struct {
@@ -118,6 +119,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
p.config.AnsibleEnvVars = append(p.config.AnsibleEnvVars, "ANSIBLE_SCP_IF_SSH=True")
}
if p.config.SetPackerPasswd {
p.config.AnsibleEnvVars = append(p.config.AnsibleEnvVars, "PACKER_RANDOM_PASSWORD=TEST")
}
if len(p.config.LocalPort) > 0 {
if _, err := strconv.ParseUint(p.config.LocalPort, 10, 16); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("local_port: %s must be a valid port", p.config.LocalPort))