From ecbb0e84986cb404c6fa5a2b2d4b4b4745162ebc Mon Sep 17 00:00:00 2001 From: asatara Date: Fri, 28 Mar 2014 15:22:37 -0700 Subject: [PATCH 1/2] Added ssh_address variable to vmware builders --- builder/vmware/common/ssh.go | 4 ++++ builder/vmware/common/ssh_config.go | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/builder/vmware/common/ssh.go b/builder/vmware/common/ssh.go index 7bf8bac72..0d2fdce0d 100644 --- a/builder/vmware/common/ssh.go +++ b/builder/vmware/common/ssh.go @@ -17,6 +17,10 @@ func SSHAddressFunc(config *SSHConfig) func(multistep.StateBag) (string, error) driver := state.Get("driver").(Driver) vmxPath := state.Get("vmx_path").(string) + if config.SSHHost != "" { + return fmt.Sprintf("%s:%d", config.SSHHost, config.SSHPort), nil + } + log.Println("Lookup up IP information...") f, err := os.Open(vmxPath) if err != nil { diff --git a/builder/vmware/common/ssh_config.go b/builder/vmware/common/ssh_config.go index 0eab2ac3c..b036133cc 100644 --- a/builder/vmware/common/ssh_config.go +++ b/builder/vmware/common/ssh_config.go @@ -3,6 +3,7 @@ package common import ( "errors" "fmt" + "net" "os" "time" @@ -13,6 +14,7 @@ type SSHConfig struct { SSHUser string `mapstructure:"ssh_username"` SSHKeyPath string `mapstructure:"ssh_key_path"` SSHPassword string `mapstructure:"ssh_password"` + SSHHost string `mapstructure:"ssh_host"` SSHPort uint `mapstructure:"ssh_port"` SSHSkipRequestPty bool `mapstructure:"ssh_skip_request_pty"` RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"` @@ -53,6 +55,14 @@ func (c *SSHConfig) Prepare(t *packer.ConfigTemplate) []error { } } + if c.SSHHost != "" { + if ip := net.ParseIP(c.SSHHost); ip == nil { + if _, err := net.LookupHost(c.SSHHost); err != nil { + errs = append(errs, errors.New("ssh_host is an invalid IP or hostname")) + } + } + } + if c.SSHUser == "" { errs = append(errs, errors.New("An ssh_username must be specified.")) } From 1783827c4099ec79d6dfa6b102a0162a8da2cc0c Mon Sep 17 00:00:00 2001 From: asatara Date: Tue, 22 Apr 2014 14:30:27 -0700 Subject: [PATCH 2/2] Added documentation --- website/source/docs/builders/vmware-iso.html.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/source/docs/builders/vmware-iso.html.markdown b/website/source/docs/builders/vmware-iso.html.markdown index 8de9e13ec..dd545f56a 100644 --- a/website/source/docs/builders/vmware-iso.html.markdown +++ b/website/source/docs/builders/vmware-iso.html.markdown @@ -185,6 +185,9 @@ Optional: The associated public key is expected to already be configured on the VM being prepared by some other process (kickstart, etc.). +* `ssh_host` (string) - Hostname or IP address of the host. By default, DHCP + is used to connect to the host and this field is not used. + * `ssh_password` (string) - The password for `ssh_username` to use to authenticate with SSH. By default this is the empty string.