added function to retreive winrm password from commonhelper

This commit is contained in:
Levi 2018-07-02 20:12:04 -04:00
parent 636cec8f2b
commit 68ec630fde
1 changed files with 8 additions and 1 deletions

View File

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