OpenStack builder store WinRM password for provisioners to use

This commit is contained in:
Justin Georgeson 2019-08-01 19:02:36 -05:00
parent c0e37e6045
commit c0ee859559
1 changed files with 10 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers" "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/communicator"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
@ -17,8 +18,9 @@ import (
// StepGetPassword reads the password from a booted OpenStack server and sets // StepGetPassword reads the password from a booted OpenStack server and sets
// it on the WinRM config. // it on the WinRM config.
type StepGetPassword struct { type StepGetPassword struct {
Debug bool Debug bool
Comm *communicator.Config Comm *communicator.Config
BuildName string
} }
func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { 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)) "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 return multistep.ActionContinue
} }
func (s *StepGetPassword) Cleanup(multistep.StateBag) {} func (s *StepGetPassword) Cleanup(multistep.StateBag) {
commonhelper.RemoveSharedStateFile("winrm_password", s.BuildName)
}