Issue with using winrm user different from “packer_user” with Google Cloud Platform

南楼画角 提交于 2019-12-11 18:48:39

问题


I faced an issue using packer 1.4.3. At first I faced an issue, which described in #8085 (https://circleci.com/gh/hashicorp/packer/12207#artifacts/containers/0 version) . It was successfully fixed with downloading mentioned packer version.

Currently I'm building Windows-2019 and Windows-2016 in Google Cloud Platform with packer. It works in proper way when I mention "winrm_username": "packer_user", if I use "winrm_username": "Adminitstator" or "winrm_username": "administator", I have an error below:

==> windows-2019: Waiting for the instance to become running... windows-2019: Internal IP: 10.154.21.58 windows-2019: IP: 10.154.21.58 ==> windows-2019: Using winrm communicator to connect: 10.154.21.58 ==> windows-2019: Waiting for WinRM to become available... ==> windows-2019: Timeout waiting for WinRM. ==> windows-2019: Deleting instance... windows-2019: Instance has been deleted! ==> windows-2019: Deleting disk... windows-2019: Disk has been deleted! Build 'windows-2019' errored: Timeout waiting for WinRM.

I've also tried to add timeout for waiting instance "winrm_timeout":"7m"

Below you can find my json file for building windows image with packer:

{
"name": "windows-2016",
"type": "googlecompute",
"project_id": "myProject",
"zone": "{{user zone}}",
"source_image_family": "windows-2016",
"communicator": "winrm",
"winrm_username": "Adminitstrator",
"image_name": "test-image",
"machine_type": "n1-standard-2",
"disk_size": 50,
"network_project_id": "build-test",
"subnetwork": "mynetwork",
"omit_external_ip": true,
"use_internal_ip": true,
"tags": [
"project-test
],
"winrm_insecure": true,
"winrm_use_ssl": true,
"metadata": {
"windows-startup-script-cmd": "winrm quickconfig -quiet & net user /add Adminitstrator & net localgroup administrators Adminitstrator /add & net user /add Adminitstrator & winrm set winrm/config/service/auth @{Basic="true"}"
}
}

Packer installed on centos-7.

this is output of packer_log=1

2019/09/24 09:48:31 Build debug mode: true
2019/09/24 09:48:31 Force build: false
2019/09/24 09:48:31 On error: abort
2019/09/24 09:48:31 Preparing build: windows-2016
2019/09/24 09:48:31 Debug enabled, so waiting for build to finish: windows-2016
2019/09/24 09:48:31 Starting build run: windows-2016
2019/09/24 09:48:31 Running builder: googlecompute
2019/09/24 09:48:31 [INFO] (telemetry) Starting builder googlecompute
2019/09/24 09:48:31 packer: 2019/09/24 09:48:31 [INFO] Requesting Google token via GCE API Default Client Token Source...
2019/09/24 09:48:31 packer: 2019/09/24 09:48:31 [INFO] Instantiating GCE client...
2019/09/24 09:48:32 packer: 2019/09/24 09:48:32 Error asking for input: no available tty
2019/09/24 09:48:32 packer: 2019/09/24 09:48:32 Error asking for input: no available tty
2019/09/24 09:48:38 packer: 2019/09/24 09:48:38 Retryable error: retrying for state DONE, got RUNNING
2019/09/24 09:48:40 packer: 2019/09/24 09:48:40 Retryable error: retrying for state DONE, got RUNNING
2019/09/24 09:48:43 packer: 2019/09/24 09:48:43 Error asking for input: no available tty
2019/09/24 09:48:44 packer: 2019/09/24 09:48:44 Retryable error: retrying for state DONE, got RUNNING
2019/09/24 09:48:46 packer: 2019/09/24 09:48:46 Retryable error: retrying for state DONE, got RUNNING
2019/09/24 09:49:24 packer: 2019/09/24 09:49:24 Error asking for input: no available tty
2019/09/24 09:49:24 packer: 2019/09/24 09:49:24 Error asking for input: no available tty
2019/09/24 09:49:24 packer: 2019/09/24 09:49:24 Waiting for WinRM, up to timeout: 30m0s
2019/09/24 09:49:24 packer: 2019/09/24 09:49:24 [INFO] Attempting WinRM connection...
2019/09/24 09:49:24 packer: 2019/09/24 09:49:24 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:49:54 packer: 2019/09/24 09:49:54 [ERROR] connection error: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:49:54 packer: 2019/09/24 09:49:54 [ERROR] WinRM connection err: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:49:54 packer: 2019/09/24 09:49:54 [INFO] Attempting WinRM connection...
2019/09/24 09:49:54 packer: 2019/09/24 09:49:54 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:50:24 packer: 2019/09/24 09:50:24 [ERROR] connection error: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:50:24 packer: 2019/09/24 09:50:24 [ERROR] WinRM connection err: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:50:24 packer: 2019/09/24 09:50:24 [INFO] Attempting WinRM connection...
2019/09/24 09:50:24 packer: 2019/09/24 09:50:24 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:50:54 packer: 2019/09/24 09:50:54 [ERROR] connection error: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:50:54 packer: 2019/09/24 09:50:54 [ERROR] WinRM connection err: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:50:54 packer: 2019/09/24 09:50:54 [INFO] Attempting WinRM connection...
2019/09/24 09:50:54 packer: 2019/09/24 09:50:54 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:51:24 packer: 2019/09/24 09:51:24 [ERROR] connection error: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:51:24 packer: 2019/09/24 09:51:24 [ERROR] WinRM connection err: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:51:24 packer: 2019/09/24 09:51:24 [INFO] Attempting WinRM connection...
2019/09/24 09:51:24 packer: 2019/09/24 09:51:24 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:51:54 packer: 2019/09/24 09:51:54 [ERROR] connection error: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:51:54 packer: 2019/09/24 09:51:54 [ERROR] WinRM connection err: unknown error Post https://10.154.21.194:5986/wsman: dial tcp 10.154.21.194:5986: i/o timeout
2019/09/24 09:51:54 packer: 2019/09/24 09:51:54 [INFO] Attempting WinRM connection...
2019/09/24 09:51:54 packer: 2019/09/24 09:51:54 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:09 packer: 2019/09/24 09:52:09 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:09 packer: 2019/09/24 09:52:09 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:09 packer: 2019/09/24 09:52:09 [INFO] Attempting WinRM connection...
2019/09/24 09:52:09 packer: 2019/09/24 09:52:09 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [INFO] Attempting WinRM connection...
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [INFO] Attempting WinRM connection...
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [INFO] Attempting WinRM connection...
2019/09/24 09:52:10 packer: 2019/09/24 09:52:10 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [INFO] Attempting WinRM connection...
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [INFO] Attempting WinRM connection...
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [INFO] Attempting WinRM connection...
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [INFO] Attempting WinRM connection...
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [INFO] Attempting WinRM connection...
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [INFO] Attempting WinRM connection...
2019/09/24 09:52:11 packer: 2019/09/24 09:52:11 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:12 packer: 2019/09/24 09:52:12 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:12 packer: 2019/09/24 09:52:12 [ERROR] WinRM connection err: http response error: 401 - invalid content type
2019/09/24 09:52:12 packer: 2019/09/24 09:52:12 [INFO] Attempting WinRM connection...
2019/09/24 09:52:12 packer: 2019/09/24 09:52:12 [DEBUG] connecting to remote shell using WinRM
2019/09/24 09:52:12 packer: 2019/09/24 09:52:12 [ERROR] connection error: http response error: 401 - invalid content type
2019/09/24 09:52:12 packer: 2019/09/24 09:52:12 [ERROR] WinRM connection err: http response error: 401 - invalid content type

Has anyone faced with such case?

Regards, Ihor


回答1:


The Windows images that GCP provides already have a local user named Administrator, but it is disabled by default. Using a user name other than Administrator is therefore the right way to go.



来源:https://stackoverflow.com/questions/58130151/issue-with-using-winrm-user-different-from-packer-user-with-google-cloud-platf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!