diff --git a/builder/vmware/builder.go b/builder/vmware/builder.go index d8a8f27b6..20777a4dc 100644 --- a/builder/vmware/builder.go +++ b/builder/vmware/builder.go @@ -33,6 +33,7 @@ type config struct { ISOUrl string `mapstructure:"iso_url"` VMName string `mapstructure:"vm_name"` OutputDir string `mapstructure:"output_directory"` + Headless bool `mapstructure:"headless"` HTTPDir string `mapstructure:"http_directory"` HTTPPortMin uint `mapstructure:"http_port_min"` HTTPPortMax uint `mapstructure:"http_port_max"` diff --git a/builder/vmware/driver.go b/builder/vmware/driver.go index d363aa001..24adf06a5 100644 --- a/builder/vmware/driver.go +++ b/builder/vmware/driver.go @@ -19,7 +19,7 @@ type Driver interface { IsRunning(string) (bool, error) // Start starts a VM specified by the path to the VMX given. - Start(string) error + Start(string, bool) error // Stop stops a VM specified by the path to the VMX given. Stop(string) error @@ -70,8 +70,13 @@ func (d *Fusion5Driver) IsRunning(vmxPath string) (bool, error) { return false, nil } -func (d *Fusion5Driver) Start(vmxPath string) error { - cmd := exec.Command(d.vmrunPath(), "-T", "fusion", "start", vmxPath, "gui") +func (d *Fusion5Driver) Start(vmxPath string, headless bool) error { + guiArgument := "gui" + if headless == true { + guiArgument = "nogui" + } + + cmd := exec.Command(d.vmrunPath(), "-T", "fusion", "start", vmxPath, guiArgument) if _, _, err := d.runAndLog(cmd); err != nil { return err } diff --git a/builder/vmware/step_run.go b/builder/vmware/step_run.go index 2818571c3..8a19e22fb 100644 --- a/builder/vmware/step_run.go +++ b/builder/vmware/step_run.go @@ -33,7 +33,7 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction { s.vmxPath = vmxPath ui.Say("Starting virtual machine...") - if err := driver.Start(vmxPath); err != nil { + if err := driver.Start(vmxPath, config.Headless); err != nil { err := fmt.Errorf("Error starting VM: %s", err) state["error"] = err ui.Error(err.Error())