add option to skip vnc phase and update docs

This commit is contained in:
nictrix 2017-09-20 20:07:21 -07:00 committed by Matthew Hooker
parent a7d25cd4c1
commit 6a238a3ef3
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
5 changed files with 21 additions and 3 deletions

View File

@ -21,6 +21,7 @@ import (
// <nothing> // <nothing>
type StepCleanVMX struct { type StepCleanVMX struct {
RemoveEthernetInterfaces bool RemoveEthernetInterfaces bool
SkipVNCDisable bool
} }
func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction { 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" vmxData[ide+"clientdevice"] = "TRUE"
} }
if !s.SkipVNCDisable {
ui.Message("Disabling VNC server...") ui.Message("Disabling VNC server...")
vmxData["remotedisplay.vnc.enabled"] = "FALSE" vmxData["remotedisplay.vnc.enabled"] = "FALSE"
}
if s.RemoveEthernetInterfaces { if s.RemoveEthernetInterfaces {
ui.Message("Removing Ethernet Interfaces...") ui.Message("Removing Ethernet Interfaces...")

View File

@ -21,6 +21,7 @@ import (
// Produces: // Produces:
// vnc_port uint - The port that VNC is configured to listen on. // vnc_port uint - The port that VNC is configured to listen on.
type StepConfigureVNC struct { type StepConfigureVNC struct {
Skip bool
VNCBindAddress string VNCBindAddress string
VNCPortMin uint VNCPortMin uint
VNCPortMax uint VNCPortMax uint
@ -76,6 +77,11 @@ func VNCPassword(skipPassword bool) string {
} }
func (s *StepConfigureVNC) Run(state multistep.StateBag) multistep.StepAction { 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) driver := state.Get("driver").(Driver)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
vmxPath := state.Get("vmx_path").(string) vmxPath := state.Get("vmx_path").(string)

View File

@ -39,9 +39,15 @@ type StepTypeBootCommand struct {
BootCommand []string BootCommand []string
VMName string VMName string
Ctx interpolate.Context Ctx interpolate.Context
Skip bool
} }
func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction { 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) debug := state.Get("debug").(bool)
driver := state.Get("driver").(Driver) driver := state.Get("driver").(Driver)
httpPort := state.Get("http_port").(uint) httpPort := state.Get("http_port").(uint)

View File

@ -259,6 +259,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
HTTPPortMax: b.config.HTTPPortMax, HTTPPortMax: b.config.HTTPPortMax,
}, },
&vmwcommon.StepConfigureVNC{ &vmwcommon.StepConfigureVNC{
Skip: b.config.BootCommand == nil,
VNCBindAddress: b.config.VNCBindAddress, VNCBindAddress: b.config.VNCBindAddress,
VNCPortMin: b.config.VNCPortMin, VNCPortMin: b.config.VNCPortMin,
VNCPortMax: b.config.VNCPortMax, 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, Headless: b.config.Headless,
}, },
&vmwcommon.StepTypeBootCommand{ &vmwcommon.StepTypeBootCommand{
Skip: b.config.BootCommand == nil,
BootCommand: b.config.BootCommand, BootCommand: b.config.BootCommand,
VMName: b.config.VMName, VMName: b.config.VMName,
Ctx: b.config.ctx, Ctx: b.config.ctx,
@ -303,6 +305,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
}, },
&vmwcommon.StepCleanVMX{ &vmwcommon.StepCleanVMX{
RemoveEthernetInterfaces: b.config.VMXConfig.VMXRemoveEthernet, RemoveEthernetInterfaces: b.config.VMXConfig.VMXRemoveEthernet,
SkipVNCDisable: b.config.BootCommand == nil,
}, },
&StepUploadVMX{ &StepUploadVMX{
RemoteType: b.config.RemoteType, RemoteType: b.config.RemoteType,

View File

@ -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 uses SSH to communicate to the ESXi machine rather than the vSphere API. At some
point, the vSphere API may be used. 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 disabled on some remote VMware Hypervisors. Please consult the appropriate
documentation on how to update VMware Hypervisor's firewall to allow these documentation on how to update VMware Hypervisor's firewall to allow these
connections. connections.