Add support for NTLM the WinRM communicator.
WinRM exposes an HTTP transport decorator that can be used for different authentication schemes. Windows on Azures requires this if one is to use the out of the box configuration.
This commit is contained in:
parent
cd83c3f2eb
commit
b57ed27352
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -329,7 +329,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/packer-community/winrmcp/winrmcp",
|
"ImportPath": "github.com/packer-community/winrmcp/winrmcp",
|
||||||
"Rev": "3d184cea22ee1c41ec1697e0d830ff0c78f7ea97"
|
"Rev": "f1bcf36a69fa2945e65dd099eee11b560fbd3346"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/pierrec/lz4",
|
"ImportPath": "github.com/pierrec/lz4",
|
||||||
|
@ -41,6 +41,11 @@ func New(config *Config) (*Communicator, error) {
|
|||||||
|
|
||||||
// Create the client
|
// Create the client
|
||||||
params := winrm.DefaultParameters()
|
params := winrm.DefaultParameters()
|
||||||
|
|
||||||
|
if config.TransportDecorator != nil {
|
||||||
|
params.TransportDecorator = config.TransportDecorator
|
||||||
|
}
|
||||||
|
|
||||||
params.Timeout = formatDuration(config.Timeout)
|
params.Timeout = formatDuration(config.Timeout)
|
||||||
client, err := winrm.NewClientWithParameters(
|
client, err := winrm.NewClientWithParameters(
|
||||||
endpoint, config.Username, config.Password, params)
|
endpoint, config.Username, config.Password, params)
|
||||||
@ -155,5 +160,6 @@ func (c *Communicator) newCopyClient() (*winrmcp.Winrmcp, error) {
|
|||||||
Insecure: c.config.Insecure,
|
Insecure: c.config.Insecure,
|
||||||
OperationTimeout: c.config.Timeout,
|
OperationTimeout: c.config.Timeout,
|
||||||
MaxOperationsPerShell: 15, // lowest common denominator
|
MaxOperationsPerShell: 15, // lowest common denominator
|
||||||
|
TransportDecorator: c.config.TransportDecorator,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
package winrm
|
package winrm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the WinRM connection
|
// Config is used to configure the WinRM connection
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Host string
|
Host string
|
||||||
Port int
|
Port int
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
Https bool
|
Https bool
|
||||||
Insecure bool
|
Insecure bool
|
||||||
|
TransportDecorator func(*http.Transport) http.RoundTripper
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package communicator
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -32,13 +33,14 @@ type Config struct {
|
|||||||
SSHFileTransferMethod string `mapstructure:"ssh_file_transfer_method"`
|
SSHFileTransferMethod string `mapstructure:"ssh_file_transfer_method"`
|
||||||
|
|
||||||
// WinRM
|
// WinRM
|
||||||
WinRMUser string `mapstructure:"winrm_username"`
|
WinRMUser string `mapstructure:"winrm_username"`
|
||||||
WinRMPassword string `mapstructure:"winrm_password"`
|
WinRMPassword string `mapstructure:"winrm_password"`
|
||||||
WinRMHost string `mapstructure:"winrm_host"`
|
WinRMHost string `mapstructure:"winrm_host"`
|
||||||
WinRMPort int `mapstructure:"winrm_port"`
|
WinRMPort int `mapstructure:"winrm_port"`
|
||||||
WinRMTimeout time.Duration `mapstructure:"winrm_timeout"`
|
WinRMTimeout time.Duration `mapstructure:"winrm_timeout"`
|
||||||
WinRMUseSSL bool `mapstructure:"winrm_use_ssl"`
|
WinRMUseSSL bool `mapstructure:"winrm_use_ssl"`
|
||||||
WinRMInsecure bool `mapstructure:"winrm_insecure"`
|
WinRMInsecure bool `mapstructure:"winrm_insecure"`
|
||||||
|
WinRMTransportDecorator func(*http.Transport) http.RoundTripper
|
||||||
}
|
}
|
||||||
|
|
||||||
// Port returns the port that will be used for access based on config.
|
// Port returns the port that will be used for access based on config.
|
||||||
|
@ -124,13 +124,14 @@ func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, cancel <-chan
|
|||||||
|
|
||||||
log.Println("[INFO] Attempting WinRM connection...")
|
log.Println("[INFO] Attempting WinRM connection...")
|
||||||
comm, err = winrm.New(&winrm.Config{
|
comm, err = winrm.New(&winrm.Config{
|
||||||
Host: host,
|
Host: host,
|
||||||
Port: port,
|
Port: port,
|
||||||
Username: user,
|
Username: user,
|
||||||
Password: password,
|
Password: password,
|
||||||
Timeout: s.Config.WinRMTimeout,
|
Timeout: s.Config.WinRMTimeout,
|
||||||
Https: s.Config.WinRMUseSSL,
|
Https: s.Config.WinRMUseSSL,
|
||||||
Insecure: s.Config.WinRMInsecure,
|
Insecure: s.Config.WinRMInsecure,
|
||||||
|
TransportDecorator: s.Config.WinRMTransportDecorator,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] WinRM connection err: %s", err)
|
log.Printf("[ERROR] WinRM connection err: %s", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user