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
|
@ -329,7 +329,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/packer-community/winrmcp/winrmcp",
|
||||
"Rev": "3d184cea22ee1c41ec1697e0d830ff0c78f7ea97"
|
||||
"Rev": "f1bcf36a69fa2945e65dd099eee11b560fbd3346"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/pierrec/lz4",
|
||||
|
|
|
@ -41,6 +41,11 @@ func New(config *Config) (*Communicator, error) {
|
|||
|
||||
// Create the client
|
||||
params := winrm.DefaultParameters()
|
||||
|
||||
if config.TransportDecorator != nil {
|
||||
params.TransportDecorator = config.TransportDecorator
|
||||
}
|
||||
|
||||
params.Timeout = formatDuration(config.Timeout)
|
||||
client, err := winrm.NewClientWithParameters(
|
||||
endpoint, config.Username, config.Password, params)
|
||||
|
@ -155,5 +160,6 @@ func (c *Communicator) newCopyClient() (*winrmcp.Winrmcp, error) {
|
|||
Insecure: c.config.Insecure,
|
||||
OperationTimeout: c.config.Timeout,
|
||||
MaxOperationsPerShell: 15, // lowest common denominator
|
||||
TransportDecorator: c.config.TransportDecorator,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package winrm
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -13,4 +14,5 @@ type Config struct {
|
|||
Timeout time.Duration
|
||||
Https bool
|
||||
Insecure bool
|
||||
TransportDecorator func(*http.Transport) http.RoundTripper
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package communicator
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
@ -39,6 +40,7 @@ type Config struct {
|
|||
WinRMTimeout time.Duration `mapstructure:"winrm_timeout"`
|
||||
WinRMUseSSL bool `mapstructure:"winrm_use_ssl"`
|
||||
WinRMInsecure bool `mapstructure:"winrm_insecure"`
|
||||
WinRMTransportDecorator func(*http.Transport) http.RoundTripper
|
||||
}
|
||||
|
||||
// Port returns the port that will be used for access based on config.
|
||||
|
|
|
@ -131,6 +131,7 @@ func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, cancel <-chan
|
|||
Timeout: s.Config.WinRMTimeout,
|
||||
Https: s.Config.WinRMUseSSL,
|
||||
Insecure: s.Config.WinRMInsecure,
|
||||
TransportDecorator: s.Config.WinRMTransportDecorator,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] WinRM connection err: %s", err)
|
||||
|
|
Loading…
Reference in New Issue