From c0ee85955990d6f16d773d448b44946dd8de457d Mon Sep 17 00:00:00 2001 From: Justin Georgeson Date: Thu, 1 Aug 2019 19:02:36 -0500 Subject: [PATCH] OpenStack builder store WinRM password for provisioners to use --- builder/openstack/step_get_password.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/builder/openstack/step_get_password.go b/builder/openstack/step_get_password.go index 0c173fa7a..c97bc4944 100644 --- a/builder/openstack/step_get_password.go +++ b/builder/openstack/step_get_password.go @@ -8,6 +8,7 @@ import ( "time" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + commonhelper "github.com/hashicorp/packer/helper/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -17,8 +18,9 @@ import ( // StepGetPassword reads the password from a booted OpenStack server and sets // it on the WinRM config. type StepGetPassword struct { - Debug bool - Comm *communicator.Config + Debug bool + Comm *communicator.Config + BuildName string } func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { @@ -76,7 +78,12 @@ func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) mul "Password (since debug is enabled) \"%s\"", s.Comm.WinRMPassword)) } + commonhelper.SetSharedState("winrm_password", s.Comm.WinRMPassword, s.BuildName) + packer.LogSecretFilter.Set(s.Comm.WinRMPassword) + return multistep.ActionContinue } -func (s *StepGetPassword) Cleanup(multistep.StateBag) {} +func (s *StepGetPassword) Cleanup(multistep.StateBag) { + commonhelper.RemoveSharedStateFile("winrm_password", s.BuildName) +}