diff --git a/helper/communicator/config.go b/helper/communicator/config.go index 052cfe2ee..a39262abb 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -42,6 +42,7 @@ type Config struct { WinRMTimeout time.Duration `mapstructure:"winrm_timeout"` WinRMUseSSL bool `mapstructure:"winrm_use_ssl"` WinRMInsecure bool `mapstructure:"winrm_insecure"` + WinRMUseNTLM bool `mapstructure:"winrm_use_ntlm"` WinRMTransportDecorator func() winrm.Transporter } @@ -187,6 +188,10 @@ func (c *Config) prepareWinRM(ctx *interpolate.Context) []error { c.WinRMTimeout = 30 * time.Minute } + if c.WinRMUseNTLM == true { + c.WinRMTransportDecorator = func() winrm.Transporter { return &winrm.ClientNTLM{} } + } + var errs []error if c.WinRMUser == "" { errs = append(errs, errors.New("winrm_username must be specified.")) diff --git a/helper/communicator/config_test.go b/helper/communicator/config_test.go index a81dba53f..c5af24114 100644 --- a/helper/communicator/config_test.go +++ b/helper/communicator/config_test.go @@ -1,9 +1,11 @@ package communicator import ( + "reflect" "testing" "github.com/hashicorp/packer/template/interpolate" + "github.com/masterzen/winrm" ) func testConfig() *Config { @@ -101,6 +103,29 @@ func TestConfig_winrm_port_ssl(t *testing.T) { } +func TestConfig_winrm_use_ntlm(t *testing.T) { + c := &Config{ + Type: "winrm", + WinRMUser: "admin", + WinRMUseNTLM: true, + } + if err := c.Prepare(testContext(t)); len(err) > 0 { + t.Fatalf("bad: %#v", err) + } + + if c.WinRMTransportDecorator == nil { + t.Fatalf("WinRMTransportDecorator not set.") + } + + expected := &winrm.ClientNTLM{} + actual := c.WinRMTransportDecorator() + + if !reflect.DeepEqual(expected, actual) { + t.Fatalf("WinRMTransportDecorator isn't ClientNTLM.") + } + +} + func TestConfig_winrm(t *testing.T) { c := &Config{ Type: "winrm",