Closed robbiepc30 closed 8 years ago
I have seen this before while debugging templates. It usually happens because the sysprep command had problems. In my experience its almost always because the unattend file it points to does not exist. In my templates, I copy a post unattenf file to C:/Windows/Panther/Unattend/unattend.xml but if you don't do that copy and then ask sysprep to run and use that file. It wont actually shutdown the box and packer will timeout.
hmm. I'll double check. I believe it is copying the unattend file over, I didn't change anything in the provision scripts (Except for comment some stuff out like removing extra files, win update etc... to speed up troubleshooting this problem, but the part where it copies the unattend.xml is there).
It does seem to sysprep and shutdown the vm , just that packer never seems to know. and never gets passed that part.
All I have to do is comment out the part of the batch file that blocks WinRM and it will complete in packer, but then it seems to cause issues for vagrant when it connects via WinRM on the first boot and then does a reboot, causing vagrant to tear down the vm (not quite sure what is going on there)
I am on MaxOSX 10.11.5 using the latest version of packer
oh interesting. Well, I'm about to refactor out that winrm disabling there anyways. TBH: I cant recall why I added that.
I just remembered why I block the winrm port. On first boot during vagrant up
, the WinRM and other services are starting and stopping and restarting and somewhere in the middle of all of that vagrant finds that WinRM is accessible but something is shutdown in the middle of its connection attempt sometimes resulting in a strange error.
I work around this by disabling the WinRM firewall in the shutdown command and turning it back on in the SetupComplete.cmd file. This way while the box is going through its first boot cycles of restarting services, it cant get to WinRM. Then once its fully up it runs SetupComplete and the WinRM port is made accessible.
I've not seen it interfering with the shutdown.
Ok, thanks, thats what I figured. It might just be with the packer parallels build provider. I figured out a workaround. Instead of disabling WinRM I just change the service startup type to manual, and then on SetupComplete I changed it back to auto and start the WinRM service.
Replaced the WinRM firewall rule with this in PackerShutdown.bat
sc config winrm start=demand
then replaced the WinRM firewall rule in SetupComplete with this
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm
I've ran into an issue when packer tries to shutdown the VM when it issues the shutdown command which executes PackerShutdown.bat It will stay stuck on Gracefully halting virtual machine... and will never proceed. I have tested by placing a comment line for the part that disables WinRM by typing REM in front of the line and it then works. However that causes another problem when using vagrant to start the machine it starts up connects to WinRM and then when sys prep reboots the machine vagrant looses the connection and forcibly removes the machine (I think vagrant thinks something went wrong and removes it).
Debug output with "netsh advfirewall firewall set rule name="WinRM-HTTP" new action=block" commented out on the PackerShutdown.bat. This will allow packer to complete but seems to cause issues with vagrant when WinRM is enabled during sys prep.
Debug output with "netsh advfirewall firewall set rule name="WinRM-HTTP" new action=block". This gets hung on Gracefully halting virtual machine...
It doesn't ever get pass the last line. The VM does get powered down though it just seems like packer never knows this
Any ideas of what is causing this? it seems like if it looses connection to WinRM during shutdown before it gets a successful return code from the PackerShutdown.bat it hangs
I am using the vbox-2012r2.json i've modified it to work with parallels.