From ec6f8264bf84f139369e782312dbd8a7f7925e3f Mon Sep 17 00:00:00 2001 From: Richard Nienaber Date: Mon, 16 Apr 2018 10:56:26 +0100 Subject: [PATCH 1/3] fix winrm password access in google compute --- builder/googlecompute/step_create_windows_password.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builder/googlecompute/step_create_windows_password.go b/builder/googlecompute/step_create_windows_password.go index 3386f6fbc..a389ad97a 100644 --- a/builder/googlecompute/step_create_windows_password.go +++ b/builder/googlecompute/step_create_windows_password.go @@ -13,6 +13,7 @@ import ( "os" "time" + commonhelper "github.com/hashicorp/packer/helper/common" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -112,6 +113,7 @@ func (s *StepCreateWindowsPassword) Run(_ context.Context, state multistep.State } state.Put("winrm_password", data.password) + commonhelper.SetSharedState("winrm_password", data.password) return multistep.ActionContinue } From db65c99bf4d53d1259870d07059bedac8711a874 Mon Sep 17 00:00:00 2001 From: Richard Nienaber Date: Tue, 24 Apr 2018 10:35:27 +0100 Subject: [PATCH 2/3] update code based on master and update docs --- builder/googlecompute/step_create_windows_password.go | 2 +- website/source/docs/provisioners/powershell.html.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/googlecompute/step_create_windows_password.go b/builder/googlecompute/step_create_windows_password.go index a389ad97a..38d52d869 100644 --- a/builder/googlecompute/step_create_windows_password.go +++ b/builder/googlecompute/step_create_windows_password.go @@ -113,7 +113,7 @@ func (s *StepCreateWindowsPassword) Run(_ context.Context, state multistep.State } state.Put("winrm_password", data.password) - commonhelper.SetSharedState("winrm_password", data.password) + commonhelper.SetSharedState("winrm_password", data.password, c.PackerConfig.PackerBuildName) return multistep.ActionContinue } diff --git a/website/source/docs/provisioners/powershell.html.md b/website/source/docs/provisioners/powershell.html.md index 0a97d41ac..602cddbb3 100644 --- a/website/source/docs/provisioners/powershell.html.md +++ b/website/source/docs/provisioners/powershell.html.md @@ -73,7 +73,7 @@ Optional parameters: inject prior to the execute\_command. The format should be `key=value`. Packer injects some environmental variables by default into the environment, as well, which are covered in the section below. - If you are running on AWS or Azure and would like to access the generated + If you are running on AWS, Azure or Google Compute and would like to access the generated password that Packer uses to connect to the instance via WinRM, you can use the template variable `{{.WinRMPassword}}` to set this as an environment variable. For example: @@ -101,8 +101,8 @@ Optional parameters: - `elevated_user` and `elevated_password` (string) - If specified, the PowerShell script will be run with elevated privileges using the given - Windows user. If you are running a build on AWS and would like to run using - the AWS-generated password that Packer uses to connect to the instance via, + Windows user. If you are running a build on AWS, Azure or Google Compute and would like to run using + the generated password that Packer uses to connect to the instance via, WinRM, you may do so by using the template variable {{.WinRMPassword}}. For example: From 2cfbb83b70f3a1c7159cd346f44d14394e0328c1 Mon Sep 17 00:00:00 2001 From: Richard Nienaber Date: Tue, 24 Apr 2018 10:36:54 +0100 Subject: [PATCH 3/3] fix typo --- website/source/docs/provisioners/powershell.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/provisioners/powershell.html.md b/website/source/docs/provisioners/powershell.html.md index 602cddbb3..160fe7fab 100644 --- a/website/source/docs/provisioners/powershell.html.md +++ b/website/source/docs/provisioners/powershell.html.md @@ -102,7 +102,7 @@ Optional parameters: - `elevated_user` and `elevated_password` (string) - If specified, the PowerShell script will be run with elevated privileges using the given Windows user. If you are running a build on AWS, Azure or Google Compute and would like to run using - the generated password that Packer uses to connect to the instance via, + the generated password that Packer uses to connect to the instance via WinRM, you may do so by using the template variable {{.WinRMPassword}}. For example: