diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index d6e785c70..0f92c9ef4 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -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))