mwrock / packer-templates

Templates for creating vagrant boxes
Other
535 stars 250 forks source link

HyperV for 2012R2 stuck waiting for WINRM to become available #91

Open guillemsola opened 7 years ago

guillemsola commented 7 years ago

Hi,

I just tried to build the hyperv for 2012R2 but gets stuck waiting for WinRM to become available

image

I tried to log to the image IP with Enter-PSSession -ComputerName 169.254.27.232 -UseSSL -Credential $credentials without success. Then I log in the machine and run the winrm quickconfig which said that it was not enabled for remote access. I enable it but still couldn't connect.

As ipconfig in machine showed a IP 169.254.27.232 I installed the Web-Server role and I could connect to it with it but not with the IP from the packer log.

I followed suggestions from this related repo to test some things.

guillemsola commented 7 years ago

Tested it with 2016 hyper v and it can connect with WinRM

image

guillemsola commented 7 years ago

I been investigating a bit more on this issue and it turns out that de default network switch that packer creates in hyper-v is an internal network.

From my understanding then no internet is available thus is not possible to download the provisioning script and install all the required windows updates.

As a workaround I changed it manually to external and now the process is able to move forward.

The nice thing would be to use the NAT feature only available through powershell and create an internal network with internet access.

rconde-bt commented 5 years ago

I encountered the same issue today while trying to build for Hyper-V. I had to create an external switch:

image

Then I commented out the switch_name line from hyperv-2012r2.json:

λ git diff
diff --git a/hyperv-2012r2.json b/hyperv-2012r2.json
index aaff5a2..8a1847f 100644
--- a/hyperv-2012r2.json
+++ b/hyperv-2012r2.json
@@ -13,7 +13,6 @@
       "winrm_timeout": "12h",
       "shutdown_command": "a:/PackerShutdown.bat",
       "shutdown_timeout": "15m",
-      "switch_name": "internal_switch",
       "floppy_files": [
         "answer_files/2012_r2{{user `core`}}/Autounattend.xml",
         "scripts/postunattend.xml",

Is there a better way? I'd like it to create an external network switch on its own without me having to do it in the GUI.