Hello Team,
We are working on below scenario, but WinRm connectivity is not consistent.
We are trying to create a Windows image using packer and running ansile provisioner to run some playbooks.
But we found that for initial 2,3 build WinRm will be connected after that it got stuck in same step.
Can you please suggest why this inconsistency is present.
We are using packer version Packer v1.5.1
Image name: 2012 R2 server
Attaching screenshot for both:
Please note if we will again the build, next day it will connect for 2, 3 times and again same issue.
Regards,
Purnima
Hi, thanks for reaching out.
In order to help you debug this we need a working minimal template that reproduces the issue, and full debug logs (set the env var PACKER_LOG=1 to get debug logs instead of the normal low-verbosity logs) linked in a gist.
Thanks!
Please find packer log and used template. Please run the build 3,4 times and we will start facing the issue.
Template :
{
"builders": [
{
"type": "azure-arm",
"subscription_id": "{{user `subscription_id`}}",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"tenant_id": "{{user `tenant_id`}}",
"managed_image_resource_group_name": "myPackerGroup",
"managed_image_name": "Windowsimage-{{timestamp}}",
"temp_compute_name": "packeransible2",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2012-R2-Datacenter",
"communicator": "winrm",
"winrm_username": "packer",
"winrm_password": "packer",
"winrm_use_ssl": true,
"winrm_insecure": true,
"winrm_timeout": "10m",
"virtual_network_name": "myPackerGroup-vnet",
"virtual_network_subnet_name": "default",
"private_virtual_network_with_public_ip": "true",
"build_resource_group_name": "myPackerGroup",
"azure_tags": {
"Managed": "yes",
"dept": "Devops",
"task": "Image deployment"
},
"vm_size": "Standard_DS1_v2"
}
],
"provisioners": [
{
"type": "powershell",
"script": "./create_user.ps1"
},
{
"type": "ansible",
"ansible_env_vars": ["PACKER_BUILD_NAME={{ build_name }}", "PACKER_HOST={{build `Host`}}", "WINRM_PASSWORD={{.WinRMPassword}}" ],
"playbook_file": "./Win_SAAC/configure.yml",
"extra_arguments": [ "-vvvv" ]
}
]
}
Error:
2020/05/11 02:50:28 packer-builder-azure-arm plugin: Error asking for input: no available tty
2020/05/11 02:50:28 packer-builder-azure-arm plugin: Waiting for WinRM, up to timeout: 10m0s
2020/05/11 02:50:28 ui: ESC[1;32m==> azure-arm: Waiting for WinRM to become available...ESC[0m
2020/05/11 02:50:28 packer-builder-azure-arm plugin: [INFO] Attempting WinRM connection...
2020/05/11 02:50:28 packer-builder-azure-arm plugin: [DEBUG] connecting to remote shell using WinRM
2020/05/11 02:50:29 packer-builder-azure-arm plugin: [ERROR] connection error: unknown error Post https://<<destination ip>>:5986/wsman: read tcp <<Source ip>>
7:60810-><<destination ip>>:5986: read: connection reset by peer
2020/05/11 02:50:29 packer-builder-azure-arm plugin: [ERROR] WinRM connection err: unknown error Post https://<<destination ip>>:5986/wsman: read tcp <<Source ip>>
3.227:60810-><<destination ip>>:5986: read: connection reset by peer
2020/05/11 02:50:34 packer-builder-azure-arm plugin: [INFO] Attempting WinRM connection...
2020/05/11 02:50:34 packer-builder-azure-arm plugin: [DEBUG] connecting to remote shell using WinRM
2020/05/11 02:50:34 packer-builder-azure-arm plugin: [ERROR] connection error: unknown error Post https://<<destination ip>>:5986/wsman: read tcp <<Source ip>>:60812-><<destination ip>>:5986: read: connection reset by peer
2020/05/11 02:50:34 packer-builder-azure-arm plugin: [ERROR] WinRM connection err: unknown error Post https://<<destination ip>>:5986/wsman: read tcp <<Source ip>>:60812-><<destination ip>>:5986: read: connection reset by peer
2020/05/11 02:50:39 packer-builder-azure-arm plugin: [INFO] Attempting WinRM connection...
2020/05/11 02:50:39 packer-builder-azure-arm plugin: [DEBUG] connecting to remote shell using WinRM
2020/05/11 02:50:39 packer-builder-azure-arm plugin: [ERROR] connection error: unknown error Post https://<<destination ip>>:5986/wsman: read tcp <<Source ip>>:60814-><<destination ip>>:5986: read: connection reset by peer
2020/05/11 02:50:39 packer-builder-azure-arm plugin: [ERROR] WinRM connection err: unknown error Post https://<<destination ip>>:5986/wsman: read tcp <<Source ip>>:60814-><<destination ip>>:5986: read: connection reset by peer
2020/05/11 02:50:44 packer-builder-azure-arm plugin: [INFO] Attempting WinRM connection...
2020/05/11 02:50:44 packer-builder-azure-arm plugin: [DEBUG] connecting to remote shell using WinRM
2020/05/11 02:50:45 packer-builder-azure-arm plugin: [ERROR] connection error: unknown error Post https://<<destination ip>>:5986/wsman: read tcp <<Source ip>>:60816-><<destination ip>>:5986: read: connection reset by peer
2020/05/11 02:50:45 packer-builder-azure-arm plugin: [ERROR] WinRM connection err: unknown error Post https://<<destination ip>>:5986/wsman: read tcp <<Source ip>>:60816-><<destination ip>>:5986: read: connection reset by peer
2020/05/11 02:50:50 packer-builder-azure-arm plugin: [INFO] Attempting WinRM connection...
2020/05/11 02:50:50 packer-builder-azure-arm plugin: [DEBUG] connecting to remote shell using WinRM
Regards,
Purnima
Are you able to manually connect to the instance? If you check on the Azure portal online, are you able to see the instance and necessary resource groups?
Follow-up question. Does it always pass the first 2-3 times you run per day, or is it an intermittent failure throughout the day? If it is intermittent throughout the day, I recommend increasing your winrm_timeout; For my Azure builds I tend to set the winrm_timeout to 30m.
I've seen lots of WinRM timeout issues over the last few months. Try using Standard_D2_v2
vm size, as that seems to be most stable for some reason.
305/5000
Hello Friends, I am facing the same problems. Yesterday my script worked perfectly, this morning on the first run too, but since then I can't run anymore, my size is Standard_D8s_v3 and my timeout is 30m.
Would anyone have any suggestions? And a way to ensure that the WinRM service
Hi folks, even with the high WinRM timeouts we have observed timeout issues for WinRM for certain vm sizes, as @adamrushuk called out. There is an open thread https://github.com/hashicorp/packer/issues/8658#issuecomment-600857201 with various suggestions from the Azure team and tests capturing our findings. If switching to the recommended vm sizes doesn't work please update the thread with your a sample build configuration so that we can troubleshoot further.
With that said, I do believe that this issue is a duplicate of #8658 so I am going to close it and ask that any new comments be tracked on 8658 since there are others that may be able to provide additional assistance. If you think this issue is different please let me know and I will gladly reopen.
Thanks!
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.