Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added support for winrm_password for windows custom images #114

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ ssh_port | int | Optional | The port that SSH will be available on. Defaults to
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".
***Windows Communicator Variables*** |
winrm_username | string | Optional | The username to use to connect to WinRM.
winrm_password | string | Optional | The password to use to connect to WinRM. (For custom windows images)
winrm_port | int | Optional | The port that WinRM will be available on. Defaults to port 5986.
winrm_timeout | string | Optional | The time to wait for WinRM to become available before timing out.
winrm_insecure | bool | Optional | If true, do not check server certificate chain and host name.
Expand Down
28 changes: 19 additions & 9 deletions builder/ibmcloud/vpc/winRM.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,27 @@ func winRMConfig(state multistep.StateBag) (*communicator.WinRMConfig, error) {

instanceData := state.Get("instance_data").(*vpcv1.Instance)
instanceID := *instanceData.ID
var username, password string
var err error

if config.Comm.WinRMPassword != "" {
username = config.Comm.WinRMUser
password = config.Comm.WinRMPassword
ui.Say(fmt.Sprintf("Setting provided winrm username and password (ID: %s, IP: %s)", instanceID, config.Comm.WinRMHost))

} else {
// Grabbing credentials for the instance
username, password, err = client.GrabCredentials(instanceID, state)
if err != nil {
err := fmt.Errorf("[ERROR] Error grabbing credentials: %s", err)
state.Put("error", err)
ui.Error(err.Error())
// log.Fatalf(err.Error())
return nil, nil
}
ui.Say(fmt.Sprintf("Successfully grabbed credentials for instance (ID: %s, IP: %s)", instanceID, config.Comm.WinRMHost))

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

// Configuring WinRM
comm := communicator.WinRMConfig{
Expand Down
Loading