Merge pull request #995 from asatara/add-ssh-host-vmware
Added ssh_host variable to vmware iso builder
This commit is contained in:
commit
f2186fa6ff
|
@ -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 {
|
||||
|
|
|
@ -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."))
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue