StefanScherer/docker-windows-box

Waiting for WinRM to become available

Boggin opened this issue · 10 comments

Packer v0.12.3

PS> packer build --only hyperv-iso -var 'hyperv_switchname=Primary Virtual Switch' -var 'iso_url=C:\Downloads\14393.0.161119-1705.RS1_REFRESH_SERVER_EVAL_X64FRE_EN-US.ISO' .\windows_2016_docker.json

This runs then hangs at:

==> hyperv-iso: Waiting for WinRM to become available...

The Autounattend.xml has not been modified.

Windows 10 and Windows Remote Management service is Running (Automatic).

I doubt this is a problem with the scripts as provided but I don't know where to begin fixing this.

Haven't tried the hyperv build for a long time, but the build looks like this.
The VM starts a script that installs all Windows updates, this script also may reboot several times and restarts automatically after a reboot. A powershell window should be visible during that phase.
You may have a look into the VM while packer waits for WinRM, the update script writes a logfile in C:\Windows\Temp\win-updates.log.

At the end of the update script it should enable WinRM so packer can run further provision scripts.

win-updates.ps1 hasn't run, I think, as there's no C:\Windows\Temp\win-updates.log

One of the console log lines does say:

hyperv-iso: Copying file: ./scripts/win-updates.ps1

Hm.
The scripts are copied into a virtual floppy drive, then the VM is booting with the A:\Autounattend.xml to start installation automatically. Then some scripts from this floppy drive are started.
Don't know how to investigate that. You may list all files on the floppy drive a: if all files are there that are listed in the json file in the floppy section.

May also help to do some fundamental testing:
Can you WinRM into the guest when you think it should be available?
What are the firewall rules on the guest?
Can you grab output from the script running inside the guest?

Maybe the VM does not get an IP address and only has 169.254.x.x as fallback without internet connection. The win-update.ps1 script then hangs forever in the VM. Open the Hyper-V Manager and connect to the VM to have a look at the terminal window output.

Check the virtual switch to be either an external or having an internal switch with NAT configured as described in https://github.com/charlieding/Virtualization-Documentation/tree/live/hyperv-tools/Nested#setting-up-internet-for-the-nested-environment

I'm closing this. If you still have questions, feel free to comment.

Hey this is happening to me, I'm seeing the Checking For Windows Updates message, I'm using Hyper V and building windows 2016

packer build --only=hyperv-iso windows_2016_docker.json

Hangs there for a long time. Can I skip this step?

@benjaminknox This worked for my last week, so maybe you have problems to connect to Windows Update servers in your environment. Maybe a corporate network blocks direct connections.

Ok, thank you!

When the packer.exe is unzipped from the download package, and then copied to the target. Windows may block the file.

Right click on the "packer.exe" and you will see a message

"The file is from another computer and might be blocked to help protect this computer."

Check the "Unblock" checkbox, next to the message, and apply.