For a Windows _guest_ I have a provisioner block like so:
"provisioners": [
{
"type": "shell", "inline": [
"shutdown /r /t 5 /f /d p:4:1 /c \"Packer Reboot\"",
"ping -n 30 127.0.0.1"
]
},
{
"type": "shell", "inline": [
]
}
]
The first block simply schedules a reboot and then pings itself 30 times which should take ~30 seconds - this has the same effect as sleep 30 on linux. The shell provisioner never receives the exit channel message because the script never finishes before the reboot. The problem is the next script to ping google never starts, Packer is still waiting for the first provisioner to send a complete message.
put a long sleep after the reboot so that SSH will eventually be killed automatically. Some OS configurations don't properly kill all network connections on reboot, causing the provisioner to hang despite a reboot occurring. In this case, make sure you shut down the network interfaces on reboot or in your shell script.
I've tried various things like using netsh to disable/enable the NIC, restarting the OpenSSHd service, but nothing seems to force Packer to move on. A provisioner timeout might be handy here. I'm running OpenSSH on the Windows Server 2008 R2 guest via packer-windows. Here's the relevant snippet from the log from around the time the guest reboots:
...
vmware: Approximate round trip times in milli-seconds:
2013/12/02 10:59:46 ui: vmware: Approximate round trip times in milli-seconds:
vmware: Minimum = 0ms, Maximum = 0ms, Average = 0ms
2013/12/02 10:59:46 ui: vmware: Minimum = 0ms, Maximum = 0ms, Average = 0ms
vmware: Reply from
127.0.0.1: bytes=32 time<1ms TTL=128
2013/12/02 10:59:47 ui: vmware: Reply from
127.0.0.1: bytes=32 time<1ms TTL=128
2013/12/02 10:59:51 /Users/sneal/src/packer/bin/packer-builder-vmware: 2013/12/02 10:59:51 Opening conn for SSH to tcp
192.168.211.154:222013/12/02 11:00:06 /Users/sneal/src/packer/bin/packer-builder-vmware: 2013/12/02 11:00:06 background SSH connection checker failure: dial tcp
192.168.211.154:22: i/o timeout
2013/12/02 11:00:11 /Users/sneal/src/packer/bin/packer-builder-vmware: 2013/12/02 11:00:11 Opening conn for SSH to tcp
192.168.211.154:222013/12/02 11:00:16 /Users/sneal/src/packer/bin/packer-builder-vmware: 2013/12/02 11:00:16 Opening conn for SSH to tcp
192.168.211.154:22...