From 6a238a3ef308434a6409931f4a727d940d3403f9 Mon Sep 17 00:00:00 2001 From: nictrix Date: Wed, 20 Sep 2017 20:07:21 -0700 Subject: [PATCH] add option to skip vnc phase and update docs --- builder/vmware/common/step_clean_vmx.go | 7 +++++-- builder/vmware/common/step_configure_vnc.go | 6 ++++++ builder/vmware/common/step_type_boot_command.go | 6 ++++++ builder/vmware/iso/builder.go | 3 +++ website/source/docs/builders/vmware-iso.html.md | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/builder/vmware/common/step_clean_vmx.go b/builder/vmware/common/step_clean_vmx.go index d016f35a3..59f370aff 100644 --- a/builder/vmware/common/step_clean_vmx.go +++ b/builder/vmware/common/step_clean_vmx.go @@ -21,6 +21,7 @@ import ( // type StepCleanVMX struct { RemoveEthernetInterfaces bool + SkipVNCDisable bool } func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction { @@ -59,8 +60,10 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction { vmxData[ide+"clientdevice"] = "TRUE" } - ui.Message("Disabling VNC server...") - vmxData["remotedisplay.vnc.enabled"] = "FALSE" + if !s.SkipVNCDisable { + ui.Message("Disabling VNC server...") + vmxData["remotedisplay.vnc.enabled"] = "FALSE" + } if s.RemoveEthernetInterfaces { ui.Message("Removing Ethernet Interfaces...") diff --git a/builder/vmware/common/step_configure_vnc.go b/builder/vmware/common/step_configure_vnc.go index 4b6a6cdae..b591573a0 100644 --- a/builder/vmware/common/step_configure_vnc.go +++ b/builder/vmware/common/step_configure_vnc.go @@ -21,6 +21,7 @@ import ( // Produces: // vnc_port uint - The port that VNC is configured to listen on. type StepConfigureVNC struct { + Skip bool VNCBindAddress string VNCPortMin uint VNCPortMax uint @@ -76,6 +77,11 @@ func VNCPassword(skipPassword bool) string { } func (s *StepConfigureVNC) Run(state multistep.StateBag) multistep.StepAction { + if s.Skip { + log.Println("Skipping VNC configuration step...") + return multistep.ActionContinue + } + driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmxPath := state.Get("vmx_path").(string) diff --git a/builder/vmware/common/step_type_boot_command.go b/builder/vmware/common/step_type_boot_command.go index e82a07031..7f2841fa8 100644 --- a/builder/vmware/common/step_type_boot_command.go +++ b/builder/vmware/common/step_type_boot_command.go @@ -39,9 +39,15 @@ type StepTypeBootCommand struct { BootCommand []string VMName string Ctx interpolate.Context + Skip bool } func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction { + if s.Skip { + log.Println("Skipping boot command step...") + return multistep.ActionContinue + } + debug := state.Get("debug").(bool) driver := state.Get("driver").(Driver) httpPort := state.Get("http_port").(uint) diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 688f52d72..ffa763c50 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -259,6 +259,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe HTTPPortMax: b.config.HTTPPortMax, }, &vmwcommon.StepConfigureVNC{ + Skip: b.config.BootCommand == nil, VNCBindAddress: b.config.VNCBindAddress, VNCPortMin: b.config.VNCPortMin, VNCPortMax: b.config.VNCPortMax, @@ -273,6 +274,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Headless: b.config.Headless, }, &vmwcommon.StepTypeBootCommand{ + Skip: b.config.BootCommand == nil, BootCommand: b.config.BootCommand, VMName: b.config.VMName, Ctx: b.config.ctx, @@ -303,6 +305,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe }, &vmwcommon.StepCleanVMX{ RemoveEthernetInterfaces: b.config.VMXConfig.VMXRemoveEthernet, + SkipVNCDisable: b.config.BootCommand == nil, }, &StepUploadVMX{ RemoteType: b.config.RemoteType, diff --git a/website/source/docs/builders/vmware-iso.html.md b/website/source/docs/builders/vmware-iso.html.md index 4c8c79b8b..137c7a704 100644 --- a/website/source/docs/builders/vmware-iso.html.md +++ b/website/source/docs/builders/vmware-iso.html.md @@ -446,7 +446,7 @@ various files locally, and uploads these to the remote machine. Packer currently uses SSH to communicate to the ESXi machine rather than the vSphere API. At some point, the vSphere API may be used. -Packer also requires VNC to issue boot commands during a build, which may be +Packer also requires VNC if issuing boot commands during a build, which may be disabled on some remote VMware Hypervisors. Please consult the appropriate documentation on how to update VMware Hypervisor's firewall to allow these connections.