Skip to content

Commit bf617f5

Browse files
uibmastha-jain
andauthored
fix: added support for winrm_password for windows custom images (#114)
* Added winrm_login_password support Signed-off-by: Ujjwal Kumar <ujjwal.kumar1@ibm.com> * fixed winrm_password attribute --------- Signed-off-by: Ujjwal Kumar <ujjwal.kumar1@ibm.com> Co-authored-by: Astha Jain <astha.jain@ibm.com>
1 parent 14a1015 commit bf617f5

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ ssh_port | int | Optional | The port that SSH will be available on. Defaults to
225225
ssh_timeout | string | Optional | The time to wait for SSH to become available before timing out. The format of this value is a duration such as "5s" or "5m".
226226
***Windows Communicator Variables*** |
227227
winrm_username | string | Optional | The username to use to connect to WinRM.
228+
winrm_password | string | Optional | The password to use to connect to WinRM. (For custom windows images)
228229
winrm_port | int | Optional | The port that WinRM will be available on. Defaults to port 5986.
229230
winrm_timeout | string | Optional | The time to wait for WinRM to become available before timing out.
230231
winrm_insecure | bool | Optional | If true, do not check server certificate chain and host name.

builder/ibmcloud/vpc/winRM.go

+19-9
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,27 @@ func winRMConfig(state multistep.StateBag) (*communicator.WinRMConfig, error) {
1616

1717
instanceData := state.Get("instance_data").(*vpcv1.Instance)
1818
instanceID := *instanceData.ID
19+
var username, password string
20+
var err error
21+
22+
if config.Comm.WinRMPassword != "" {
23+
username = config.Comm.WinRMUser
24+
password = config.Comm.WinRMPassword
25+
ui.Say(fmt.Sprintf("Setting provided winrm username and password (ID: %s, IP: %s)", instanceID, config.Comm.WinRMHost))
26+
27+
} else {
28+
// Grabbing credentials for the instance
29+
username, password, err = client.GrabCredentials(instanceID, state)
30+
if err != nil {
31+
err := fmt.Errorf("[ERROR] Error grabbing credentials: %s", err)
32+
state.Put("error", err)
33+
ui.Error(err.Error())
34+
// log.Fatalf(err.Error())
35+
return nil, nil
36+
}
37+
ui.Say(fmt.Sprintf("Successfully grabbed credentials for instance (ID: %s, IP: %s)", instanceID, config.Comm.WinRMHost))
1938

20-
// Grabbing credentials for the instance
21-
username, password, err := client.GrabCredentials(instanceID, state)
22-
if err != nil {
23-
err := fmt.Errorf("[ERROR] Error grabbing credentials: %s", err)
24-
state.Put("error", err)
25-
ui.Error(err.Error())
26-
// log.Fatalf(err.Error())
27-
return nil, nil
2839
}
29-
ui.Say(fmt.Sprintf("Successfully grabbed credentials for instance (ID: %s, IP: %s)", instanceID, config.Comm.WinRMHost))
3040

3141
// Configuring WinRM
3242
comm := communicator.WinRMConfig{

0 commit comments

Comments
 (0)