joefitzgerald / packer-windows

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

Windows 2012 R2 in Waiting for SSH to become available... #258

Closed kaluznyt closed 6 years ago

kaluznyt commented 6 years ago

Hello,

I'm new to packer, and I'm trying to create a virtualbox image based on windows_2012_r2 script and MSDN iso. Everything seems fine until script hangs on:

    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1515149748 --cpus 2
==> virtualbox-iso: Starting the virtual machine...
==> virtualbox-iso: Waiting 4m0s for boot...
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Waiting for SSH to become available...

I enabled GUI so I can see what is going on in the machine, and it is like this:

image

If I ran manually the command from section "Install OpenSSH".

    <SynchronousCommand wcm:action="add">
                    <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart</CommandLine>
                    <Description>Install OpenSSH</Description>
                    <Order>99</Order>
                    <RequiresUserInput>true</RequiresUserInput>
                </SynchronousCommand>

image

Then the packer script continues:

image

Seems like the OpenSSH command isn't executed at all. Any hints ?

This is my Autounattend.xml script part with these sections (I wanted to skip windows updates).

          ```
            <SynchronousCommand wcm:action="add">
                <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart</CommandLine>
                <Description>Install OpenSSH</Description>
                <Order>99</Order>
                <RequiresUserInput>true</RequiresUserInput>
            </SynchronousCommand>

            <!-- END WITHOUT WINDOWS UPDATES -->
            <!-- WITH WINDOWS UPDATES -->
            <!-- <SynchronousCommand wcm:action="add">
                <CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine>
                <Order>98</Order>
                <Description>Enable Microsoft Updates</Description>
            </SynchronousCommand>
            <SynchronousCommand wcm:action="add">
                <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1</CommandLine>
                <Description>Install Windows Updates</Description>
                <Order>100</Order>
                <RequiresUserInput>true</RequiresUserInput>
            </SynchronousCommand>
            -->
            <!-- END WITH WINDOWS UPDATES -->
kaluznyt commented 6 years ago

Actually probably a better solution would be to skip to winrm communicator alltogether but I can see it only for win 10 (https://github.com/joefitzgerald/packer-windows/blob/jf/switch-to-winrm/windows_10.json), but I'll try to modify the files for w2012r2

kaluznyt commented 6 years ago

Are there any logs from the boot scripts execution ? As I saw some redness on some scripts after first boot, but that's too fast to see exactly what's that.

kaluznyt commented 6 years ago

Sorry, don't bother, I was modifying the wrong autounattend file, everything works fine !