hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.13k stars 3.33k forks source link

Connection refused when using winrm to build windows kvm image #2445

Closed spyyang closed 9 years ago

spyyang commented 9 years ago

I use packer.0.8.0 to build windows 2012R2 image by WinRM communicator, having succeed building vmware-iso but failed to build qemu-kvm type using almost same configuration. Packer can not connect the windows instance as the log shows:

packer-builder-qemu: 2015/07/13 11:32:33 [INFO] Attempting WinRM connection...
packer-builder-qemu: 2015/07/13 11:32:33 [DEBUG] connecting to remote shell using WinRM
packer-builder-qemu: 2015/07/13 11:32:33 [ERROR] connection error: unknown error Post http://127.0.0.1:5985/wsman: dial tcp 127.0.0.1:5985: connection refused

I try CLI debugging: ps -ef |grep packer:

root 50434 50322 84 12:31 pts/2 00:04:49 /usr/bin/qemu-system-x86_64 -machine type=pc,accel=kvm -cdrom /opt/iso/win-2012R2.iso -name win2k12r2-kvm-prod -m 4096M -smp 4 -device virtio-net,netdev=user.0 -fda /tmp/packer312230827 -netdev user,id=user.0,hostfwd=tcp::3499-:5985 -drive file=/opt/packer-output/prod/spyang_test/win-2012R2/win2k12r2-kvm-prod,if=virtio,cache=writeback,discard=ignore -boot once=d -vnc 0.0.0.0:87

curl -v http://127.0.0.1:5985/wsman:

* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* connect to 127.0.0.1 port 5985 failed: Connection refused
* Failed to connect to 127.0.0.1 port 5985: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 127.0.0.1 port 5985: Connection refused

curl -v http://127.0.0.1:3499/wsman:

* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 3499 (#0)
> GET /wsman HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 127.0.0.1:3499
> Accept: */*
> 
< HTTP/1.1 405 
< Allow: POST
* Server Microsoft-HTTPAPI/2.0 is not blacklisted
< Server: Microsoft-HTTPAPI/2.0
< Date: Sun, 12 Jul 2015 21:00:58 GMT
< Connection: close
< Content-Length: 0
< 
* Closing connection 0

I suspect packer should connect to http://127.0.0.1:3499/wsman not 5985. Thanks for your help.

skvl commented 7 years ago

@spyyang how have you dealt with this issue? I can't run the qemu builder. Thank you.

UPDATE

I think I have found a solution. Just get latest version with bugfix with command:

go get -u github.com/mitchellh/packer

NB I have just run a test