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>
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...")

View File

@ -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)

View File

@ -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)

View File

@ -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,

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
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.