joefitzgerald / packer-windows

Windows Packer Templates
MIT License
1.63k stars 1.12k forks source link

Hang at "Waiting for WinRM to become available..." #157

Closed jboeshart closed 8 years ago

jboeshart commented 9 years ago

I'm doing a build of my own Win2012r2 ISO, and am seeing packer hang at "Waiting for WinRM to become available...". When I set PACKER_DEBUG=1, I can see that it's trying to connect to 127.0.0.1:5985 for WinRM, but the VirtualBox config is set with a port forwarding from 5985 to a different random port. I can see in the debug output where it sets this, but can't find where it's actually calling it and why there's a mismatch between the setting of this random port and the attempt to connect over 5985. If I manually change the port forwarding to match 5985, the connectivity is successful and build continues. Is this a defect or am I overlooking some config somewhere?

Relevant output from log files as follows.

Configuration of WinRM port: 2015/07/23 15:58:53 packer-builder-virtualbox-iso: 2015/07/23 15:58:53 Looking for available SSH port between 2222 and 4444 2015/07/23 15:58:53 packer-builder-virtualbox-iso: 2015/07/23 15:58:53 Trying port: 3410 2015/07/23 15:58:53 ui: ==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 3410) ==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 3410) 2015/07/23 15:58:53 packer-builder-virtualbox-iso: 2015/07/23 15:58:53 Executing VBoxManage: []string{"modifyvm", "win2012r2-datacenter", "--natpf1", "packerssh,tcp,127.0.0.1,3410,,5985"}

Attempt to connect to WinRM: 2015/07/23 15:59:04 ui: ==> virtualbox-iso: Waiting for WinRM to become available... ==> virtualbox-iso: Waiting for WinRM to become available... 2015/07/23 15:59:09 packer-builder-virtualbox-iso: 2015/07/23 15:59:09 [INFO] Attempting WinRM connection... 2015/07/23 15:59:09 packer-builder-virtualbox-iso: 2015/07/23 15:59:09 [DEBUG] connecting to remote shell using WinRM 2015/07/23 15:59:09 packer-builder-virtualbox-iso: 2015/07/23 15:59:09 [ERROR] connection error: unknown error Post http://127.0.0.1:5985/wsman: dial tcp 127.0.0.1:5985: connection refused 2015/07/23 15:59:09 packer-builder-virtualbox-iso: 2015/07/23 15:59:09 [ERROR] WinRM connection err: unknown error Post http://127.0.0.1:5985/wsman: dial tcp 127.0.0.1:5985: connection refused

markhuber commented 9 years ago

@jboeshart I just ran into something similar modifying the 2008r2 build. Try this hack:

"ssh_host_port_min": "5985", "ssh_host_port_max": "5985",

note that setting ssh_port didn't actually work for me, had to narrow the range to one port.

sneal commented 8 years ago

I believe this was an early Packer WinRM issue which has since been fixed. Either way, the issue belongs on core packer not packer-windows since this project doesn't (yet) support WinRM.