diff --git a/builder/proxmox/clone/builder.go b/builder/proxmox/clone/builder.go index 8f088f81d..178f73587 100644 --- a/builder/proxmox/clone/builder.go +++ b/builder/proxmox/clone/builder.go @@ -4,7 +4,6 @@ import ( proxmoxapi "github.com/Telmate/proxmox-api-go/proxmox" "github.com/hashicorp/hcl/v2/hcldec" proxmox "github.com/hashicorp/packer/builder/proxmox/common" - "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -31,13 +30,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("clone-config", &b.config) - state.Put("comm", &b.config.Comm) preSteps := []multistep.Step{ &StepSshKeyPair{ Debug: b.config.PackerDebug, DebugKeyPath: fmt.Sprintf("%s.pem", b.config.PackerBuildName), - Comm: &b.config.Comm, }, } postSteps := []multistep.Step{} @@ -51,7 +48,7 @@ type cloneVMCreator struct{} func (*cloneVMCreator) Create(vmRef *proxmoxapi.VmRef, config proxmoxapi.ConfigQemu, state multistep.StateBag) error { client := state.Get("proxmoxClient").(*proxmoxapi.Client) c := state.Get("clone-config").(*Config) - comm := state.Get("comm").(*communicator.Config) + comm := state.Get("config").(*proxmox.Config).Comm fullClone := 1 if c.FullClone.False() { diff --git a/builder/proxmox/clone/step_ssh_key_pair.go b/builder/proxmox/clone/step_ssh_key_pair.go index 96e97d5a8..2aad603bb 100644 --- a/builder/proxmox/clone/step_ssh_key_pair.go +++ b/builder/proxmox/clone/step_ssh_key_pair.go @@ -5,8 +5,8 @@ import ( "fmt" "os" + common "github.com/hashicorp/packer/builder/proxmox/common" "github.com/hashicorp/packer/common/uuid" - "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/ssh" "github.com/hashicorp/packer/packer" @@ -17,19 +17,19 @@ import ( type StepSshKeyPair struct { Debug bool DebugKeyPath string - Comm *communicator.Config } func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) + c := state.Get("config").(*common.Config) - if s.Comm.SSHPassword != "" { + if c.Comm.SSHPassword != "" { return multistep.ActionContinue } - if s.Comm.SSHPrivateKeyFile != "" { + if c.Comm.SSHPrivateKeyFile != "" { ui.Say("Using existing SSH private key for the communicator...") - privateKeyBytes, err := s.Comm.ReadSSHPrivateKeyFile() + privateKeyBytes, err := c.Comm.ReadSSHPrivateKeyFile() if err != nil { state.Put("error", err) return multistep.ActionHalt @@ -44,15 +44,15 @@ func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) mult return multistep.ActionHalt } - s.Comm.SSHPrivateKey = privateKeyBytes - s.Comm.SSHKeyPairName = kp.Comment - s.Comm.SSHTemporaryKeyPairName = kp.Comment - s.Comm.SSHPublicKey = kp.PublicKeyAuthorizedKeysLine + c.Comm.SSHPrivateKey = privateKeyBytes + c.Comm.SSHKeyPairName = kp.Comment + c.Comm.SSHTemporaryKeyPairName = kp.Comment + c.Comm.SSHPublicKey = kp.PublicKeyAuthorizedKeysLine return multistep.ActionContinue } - if s.Comm.SSHAgentAuth { + if c.Comm.SSHAgentAuth { ui.Say("Using local SSH Agent to authenticate connections for the communicator...") return multistep.ActionContinue } @@ -67,11 +67,11 @@ func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) mult return multistep.ActionHalt } - s.Comm.SSHKeyPairName = kp.Comment - s.Comm.SSHTemporaryKeyPairName = kp.Comment - s.Comm.SSHPrivateKey = kp.PrivateKeyPemBlock - s.Comm.SSHPublicKey = kp.PublicKeyAuthorizedKeysLine - s.Comm.SSHClearAuthorizedKeys = true + c.Comm.SSHKeyPairName = kp.Comment + c.Comm.SSHTemporaryKeyPairName = kp.Comment + c.Comm.SSHPrivateKey = kp.PrivateKeyPemBlock + c.Comm.SSHPublicKey = kp.PublicKeyAuthorizedKeysLine + c.Comm.SSHClearAuthorizedKeys = true ui.Say("Created ephemeral SSH key pair for communicator") diff --git a/builder/proxmox/common/builder.go b/builder/proxmox/common/builder.go index 1d33249b7..a4b407520 100644 --- a/builder/proxmox/common/builder.go +++ b/builder/proxmox/common/builder.go @@ -55,9 +55,6 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook, state state.Put("ui", ui) comm := &b.config.Comm - if state.Get("comm") != nil { - comm = state.Get("comm").(*communicator.Config) - } // Build the steps coreSteps := []multistep.Step{