hashicorp / packer-plugin-googlecompute

Packer plugin for Google Compute Builder
https://www.packer.io/docs/builders/googlecompute
Mozilla Public License 2.0
26 stars 55 forks source link

WinRM Connection Returns 401 #61

Open lmayorga1980 opened 3 years ago

lmayorga1980 commented 3 years ago

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 of the log or use the Github detailed format 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...
KyriosGN0 commented 1 month ago

im also running into this issue with windows 2022 image