joefitzgerald / packer-windows

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

Windows 7 build fails unless auto-updates are turned off #126

Closed TheBigBear closed 8 years ago

TheBigBear commented 9 years ago

I can successfully build all 'box' files in this project except for the virtualbox one for windows 7. Not sure how to debug this exaclty. But it appears to be running through many of the windows or microsoft updates, can't tell which. And it reboot s a good number of times. But eventually it comes up with no user logged in showing the password login prompt for the vagrant user. (I switched headless mode off, so I can see what is going on) But if I don't do anything it will simply time-out and erase all files. (my timeout is increased to 12 hrs ) Or if I login vagrant using the vagrant password, it seems to continue doing updates and does more reboots. But virtualbox output in the shell never goes beyond the waiting for SSH to become available. Any ideas why the vmware (using vmware_fusion provider) succeeds, but the virtualbox one times out?

StefanScherer commented 9 years ago

@TheBigBear I think in my Autounattend.xml I have put the "dis-updates.ps1" before the "win-updates.ps1" which sounds weird, but the first script just disables automatic updates while running the windows updates script. Otherwise I sometimes had the problem you describe.

Could you check if that helps in your packer environment? If this fixes the problem we could fix it in master branch as well.

StefanScherer commented 9 years ago

I just created the windows_7.json template from master branch with packer 0.7.5 and VirtualBox 4.3.20 on my MBP. A previous build with my branch worked as well. Perhaps the master branch runs into trouble if you build the boxes overnight. AFAIK the automatic updates run at 3AM.

TheBigBear commented 9 years ago

@StefanScherer Thanks for your comment. I have also put the "dis-updates.ps1" before the "win-updates.ps1", and it now finnishes building. Thanks.

That's the way my diff looks:

diff --git a/answer_files/7/Autounattend.xml b/answer_files/7/Autounattend.xml
index 996da72..580c423
--- a/answer_files/7/Autounattend.xml
+++ b/answer_files/7/Autounattend.xml
@@ -251,8 +251,14 @@
                 <!-- WITH WINDOWS UPDATES -->
                 <!-- Disable automatic updates so the system update process doesn't interfere with the update script -->
                 <SynchronousCommand wcm:action="add">
-                    <CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine>
+                    <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\dis-updates.ps1 -MaxUpdatesPerCycle 30</Comma
+                    <Description>Disable Windows Auto-Updates</Description>
                     <Order>98</Order>
+                    <RequiresUserInput>true</RequiresUserInput>
+                </SynchronousCommand>                 
+                <SynchronousCommand wcm:action="add">
+                    <CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine>
+                    <Order>99</Order>
                     <Description>Enable Microsoft Updates</Description>
                 </SynchronousCommand>
                 <SynchronousCommand wcm:action="add">
sneal commented 8 years ago

Using latest master and removing the ngen step I was able to successfully build a Win7 box