diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index fd037c6ce..a01d3f4cb 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -121,7 +121,8 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if p.config.SetPackerPasswd { - p.config.AnsibleEnvVars = append(p.config.AnsibleEnvVars, "PACKER_RANDOM_PASSWORD=TEST") + var PackerEnvVar string = fmt.Sprintf("PACKER_RANDOM_PASSWORD=%s", getWinRMPassword()) + p.config.AnsibleEnvVars = append(p.config.AnsibleEnvVars, PackerEnvVar) } if len(p.config.LocalPort) > 0 { @@ -514,6 +515,12 @@ func newSigner(privKeyFile string) (*signer, error) { return signer, nil } +func getWinRMPassword() string { + winRMPass, _ := commonhelper.RetrieveSharedState("winrm_password") + return winRMPass + +} + // Ui provides concurrency-safe access to packer.Ui. type Ui struct { sem chan int