Closed tyrken closed 9 years ago
I am running into the exact same issue. I think part of the problem with the builder scripts is that they execute all at once and there is no dependency ordering or integration with other scripts. Maybe some CM scripts might help here. Additionally, I have a few suggestions that might ease the pain.
I have wasted days on trying to get this to work. 243 updates sometimes takes 8 hours!
For anybody else doing this please detail your work arounds or publish your instructions.
We (@tyrken and myself) have worked around it by using the Host Command provisioner, and implementing a 30 second sleep on the host. This seems to work so far.
Still not ideal, but as far as work arounds go, its dead simple and seems to work.
Going forward, please use WinRM and the windows-restart
provisioner. Much better. :)
I'm trying to build windows VMware ESXi remote & Virtualbox images using Packer 0.7.1 (I can't easily upgrade to 0.7.5 as I'd have to undo some workarounds to now fixed VMWare builder bugs) from a Linux host. I'm borrowing from https://github.com/joefitzgerald/packer-windows/blob/master/scripts/win-updates.ps1 to perform windows updates during the SysPrep phase, which uses the trick of not starting the OpenSSH server until all updates & necessary reboots have finished.
However I'm also installing more packages using Shell provisioners, and so need more updates that now require a reboot. Unfortunately the standard "sleep 10" trick doesn't work - sleep too long and the shutdown terminates the execution of sleep & returns an error, which Packer interprets as a fail & gives up. Sleep too short & it starts the next provisioner which will get interrupted by the shutdown & similarly fail.
Unless some magical ability exists for Packer to know that the target is about to reboot that it tries before each remote command, what I think is needed is for the shell provisioner to retry failures N times rather than bail out on first error, perhaps with a new parameter to the provisioner to actively mark the idempotent scripts. Alternatively, a "pause" provisioner which delays the Packer run for a set time, ala the sleep hack, but locally rather than at the target.