Image 从自定义映像Google云平台运行实例时出现问题。WinRm超时
我有一个问题,运行从谷歌云平台与Packer自定义图像实例。半小时后,我遇到了一个问题(WinRM超时) 如果我使用基本Windows-2016映像,则一切都正常工作Image 从自定义映像Google云平台运行实例时出现问题。WinRm超时,image,connection-timeout,packer,winrm,packer-builder,Image,Connection Timeout,Packer,Winrm,Packer Builder,我有一个问题,运行从谷歌云平台与Packer自定义图像实例。半小时后,我遇到了一个问题(WinRM超时) 如果我使用基本Windows-2016映像,则一切都正常工作 { "builders": [ { "type": "googlecompute", "account_file": "account.json", "project_id": "my project", "source_image_family": "windows-2
{
"builders": [
{
"type": "googlecompute",
"account_file": "account.json",
"project_id": "my project",
"source_image_family": "windows-2016",
"image_family": "my-image"
"disk_size": "50",
"machine_type": "n1-standard-1",
"communicator": "winrm",
"winrm_username": "packer_user",
"winrm_insecure": true,
"winrm_use_ssl": true,
"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\"}"
},
"zone": "us-central1-a"
}
]
}
起初,我使用了“管理员”用户名,而不是packer\u用户-它不起作用()
当前,如果我正在从自定义映像(从windows-2016 gcp映像成功创建)运行实例,它会显示一个错误:“生成‘映像ami win’错误:等待WinRM超时。”
我不运行任何会影响防火墙或访问的自定义provisioner。只需从基本windows-2016映像创建实例-关闭,创建映像并使用packer进行构建:
{
"variables": {
"zone": "us-east1-b",
"winrm_user" : "packer_user",
"builder_name": ""
},
"builders": [
{
"name": "image-ami-win",
"type": "googlecompute",
"project_id": "{{user `project_id`}}",
"zone": "{{user `zone`}}",
"source_image_family": "my-family"
"communicator": "winrm",
"winrm_username": "{{user `winrm_user`}}",
"image_name": "{{user `project`}}{{user `env`}}-{{build_name}}-{{user `team`}}-{{timestamp}}",
"machine_type": "n1-standard-4",
"disk_size": 50,
"network_project_id": "{{user `network_project_id`}}",
"subnetwork": "{{user `subnetwork`}}",
"omit_external_ip": false,
"use_internal_ip": false,
"tags": [
"project-{{user `project`}}",
"branch-{{user `branch`}}",
"commit-{{user `commit_id`}}",
],
"winrm_insecure": true,
"winrm_use_ssl": true,
"metadata": {
"windows-startup-script-cmd": "winrm quickconfig -quiet & net user /add {{user `winrm_user`}} & net localgroup administrators {{user `winrm_user`}} /add & winrm set winrm/config/service/auth @{Basic=\"true\"} & powershell -Command \"& {Set-ExecutionPolicy AllSigned -Force}\""
}
}
],
"provisioners": []
}
我已经尝试运行启动脚本:
<powershell>
Enter-PSSession -ComputerName server.domain.local -Credential domain\administrator
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
</powershell>
但如果我从自定义映像运行实例,我会收到下一条消息:
2019/10/21 12:22:38 packer: 2019/10/21 12:22:38 [INFO] Attempting WinRM connection...
2019/10/21 12:22:38 packer: 2019/10/21 12:22:38 [DEBUG] connecting to remote shell using WinRM
2019/10/21 12:23:08 packer: 2019/10/21 12:23:08 [ERROR] connection error: unknown error Post https://10.154.21.219:5986/wsman: dial tcp 10.154.21.219:5986: i/o timeout
2019/10/21 12:23:08 packer: 2019/10/21 12:23:08 [ERROR] WinRM connection err: unknown error Post https://10.154.21.219:5986/wsman: dial tcp 10.154.21.219:5986: i/o timeout
2019/10/21 12:23:08 packer: 2019/10/21 12:23:08 [INFO] Attempting WinRM connection...
2019/10/21 12:23:08 packer: 2019/10/21 12:23:08 [DEBUG] connecting to remote shell using WinRM
2019/10/21 12:23:38 packer: 2019/10/21 12:23:38 [ERROR] connection error: unknown error Post https://10.154.21.219:5986/wsman: dial tcp 10.154.21.219:5986: i/o timeout
2019/10/21 12:23:38 packer: 2019/10/21 12:23:38 [ERROR] WinRM connection err: unknown error Post https://10.154.21.219:5986/wsman: dial tcp 10.154.21.219:5986: i/o timeout
2019/10/21 12:23:38 packer: 2019/10/21 12:23:38 [INFO] Attempting WinRM connection...
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [INFO] Attempting WinRM connection...
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [DEBUG] connecting to remote shell using WinRM
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [ERROR] connection error: unknown error Post https://10.154.21.203:5986/wsman: read tcp 10.147.84.31:48984->10.154.21.203:5986: read: connection reset by peer
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [ERROR] WinRM connection err: unknown error Post https://10.154.21.203:5986/wsman: read tcp 10.147.84.31:48984->10.154.21.203:5986: read: connection reset by peer
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [INFO] Attempting WinRM connection...
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [DEBUG] connecting to remote shell using WinRM
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [ERROR] connection error: unknown error Post https://10.154.21.203:5986/wsman: read tcp 10.147.84.31:48988->10.154.21.203:5986: read: connection reset by peer
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [ERROR] WinRM connection err: unknown error Post https://10.154.21.203:5986/wsman: read tcp 10.147.84.31:48988->10.154.21.203:5986: read: connection reset by peer
差异
/wsman:拨号tcp 10.154.21.219:5986:i/o超时
及
10.147.84.31:48988->10.154.21.203:5986:阅读:
。看起来有些转发正在工作,但我不明白为什么,因为打包器生成器除了图像名之外是相同的
实例应该以与我从Google Cloud Windows-2016基本映像构建实例相同的方式从自定义映像成功运行
我用的是Packer v。1.4.4
谁能帮我一下吗
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [INFO] Attempting WinRM connection...
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [DEBUG] connecting to remote shell using WinRM
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [ERROR] connection error: unknown error Post https://10.154.21.203:5986/wsman: read tcp 10.147.84.31:48984->10.154.21.203:5986: read: connection reset by peer
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [ERROR] WinRM connection err: unknown error Post https://10.154.21.203:5986/wsman: read tcp 10.147.84.31:48984->10.154.21.203:5986: read: connection reset by peer
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [INFO] Attempting WinRM connection...
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [DEBUG] connecting to remote shell using WinRM
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [ERROR] connection error: unknown error Post https://10.154.21.203:5986/wsman: read tcp 10.147.84.31:48988->10.154.21.203:5986: read: connection reset by peer
2019/10/21 10:46:08 packer: 2019/10/21 10:46:08 [ERROR] WinRM connection err: unknown error Post https://10.154.21.203:5986/wsman: read tcp 10.147.84.31:48988->10.154.21.203:5986: read: connection reset by peer