hashicorp / hashicorp/packer-plugin-googlecompute

WinRM Connection Returns 401

Open
#61 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
33
Forks
72
Avg merge
6h 47m
Merged PRs (30d)
3

Description

#### Overview of the Issue

I am trying to build a GCP Windows Image but seems like the WinRM connection is not working. Also `packer build -debug` does not print the credentials for the Administrator user. In AWS, `packer build -debug` retrieves the password properly.

#### Reproduction Steps

Using the following template as per the docs and other attributes

```
source "googlecompute" "windows-example" {
project_id = var.project_id
source_image_project_id = ["windows-cloud"]
source_image_family = "windows-2019"
#source_image = "windows-server-2019-dc-v20200813"
zone = "us-east4-a"
disk_size = 50
machine_type = "n1-standard-8"
communicator = "winrm"
winrm_username = "packer_user"
winrm_insecure = true
winrm_use_ssl = true
tags = ["packer"]
preemptible = true
image_labels = {
server_type = "windows-2019"
}
metadata = {
windows-startup-script-cmd = "winrm quickconfig -quiet & net user /add packer_user & net localgroup administrators packer_user /add & winrm set winrm/config/service/auth @{Basic=\"true\"}"
}
account_file = var.account_file_path
}

build {
sources = ["sources.googlecompute.windows-example"]
}
```

### Plugin and Packer version

Packer v1.7.8

### Simplified Packer Buildfile

If the file is longer than a few dozen lines, please include the URL to the
[gist](https://gist.github.com/) of the log or use the [Github detailed
format](https://gist.github.com/ericclemmons/b146fe5da72ca1f706b2ef72a20ac39d)
instead of posting it directly in the issue.

### Operating system and Environment details

OSX Monterrey

### Log Fragments and crash.log files

```
2021/11/22 09:36:42 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2021/11/22 09:36:45 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2021/11/22 09:36:47 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2021/11/22 09:36:49 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
googlecompute.windows-example: Instance has been created!
==> googlecompute.windows-example: Waiting for the instance to become running...
googlecompute.windows-example: IP: 34.86.165.202
2021/11/22 09:36:52 packer-builder-googlecompute plugin: Skipping step launch IAP tunnel; "iap" is false.
==> googlecompute.windows-example: Using WinRM communicator to connect: 34.86.165.202
2021/11/22 09:36:52 packer-builder-googlecompute plugin: Waiting for WinRM, up to timeout: 30m0s
==> googlecompute.windows-example: Waiting for WinRM to become available...
2021/11/22 09:36:52 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:36:52 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:37:22 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: i/o timeout
2021/11/22 09:37:22 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: i/o timeout
2021/11/22 09:37:27 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:37:27 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:37:32 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:37:32 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:37:37 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:37:37 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:37:38 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:37:38 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:37:43 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:37:43 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:37:43 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:37:43 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:37:48 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:37:48 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:38:18 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: i/o timeout
2021/11/22 09:38:18 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: i/o timeout
2021/11/22 09:38:23 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:38:23 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:38:53 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: i/o timeout
2021/11/22 09:38:53 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: i/o timeout
2021/11/22 09:38:58 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:38:58 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:39:28 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: i/o timeout
2021/11/22 09:39:28 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: i/o timeout
2021/11/22 09:39:33 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:39:33 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:39:33 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:39:33 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:39:38 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:39:38 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:39:38 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:39:38 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:39:43 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:39:43 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:39:43 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:39:43 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:39:48 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:39:48 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:39:48 packer-builder-googlecompute plugin: [ERROR] connection error: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:39:48 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: unknown error Post "https://34.86.165.202:5986/wsman": dial tcp 34.86.165.202:5986: connect: connection refused
2021/11/22 09:39:53 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:39:53 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:39:56 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:39:56 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:01 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:40:01 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:40:01 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:40:01 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:06 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:40:06 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:40:06 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:40:06 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:11 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:40:11 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:40:11 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:40:11 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:16 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:40:16 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:40:16 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:40:16 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:21 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:40:21 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:40:21 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:40:21 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:26 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:40:26 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:40:26 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:40:26 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:31 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:40:31 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:40:31 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:40:31 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:36 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...
2021/11/22 09:40:36 packer-builder-googlecompute plugin: [DEBUG] connecting to remote shell using WinRM
2021/11/22 09:40:36 packer-builder-googlecompute plugin: [ERROR] connection error: http response error: 401 - invalid content type
2021/11/22 09:40:36 packer-builder-googlecompute plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2021/11/22 09:40:41 packer-builder-googlecompute plugin: [INFO] Attempting WinRM connection...

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.