Open jshbrntt opened 1 year ago
Hello @jshbrntt, I tried your proposed change on my machine (Windows 11, 22H2 [10.0.22621.1555]) and unfortunately with that updated command I am not getting any output at all:
PS C:\> Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName "Default Switch" | Get-VMNetworkAdapterIsolation | Where-Object { $_.IsolationMode -eq "Vlan" }
PS C:\>
I've checked and compared to your Windows instance I have only one adapter connected to Default Switch
:
PS C:\> Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName "Default Switch"
Name IsManagementOs VMName SwitchName MacAddress Status IPAddresses
---- -------------- ------ ---------- ---------- ------ -----------
Host Vnic C08CB7B8-9B3C-408E-8E30-5E16A3AEB444 True Default Switch 00155D005C79 {Ok}
PS C:\>
So I am not 100% sure this is the best fix. In order to repro your issue, what else have you installed that might be using Default Switch?
Hi @jshbrntt thanks for opening up this change. From the read it appears that this fix is specific to the case where the default switch has multiple adapters, and agree with @machv that this may not be the best fix. I'm running the same build but with a single adapter in my Default Switch and run into the blue screen issue because it is not connected to an external network.
Have you considered creating a new virtual switch with just the natted adapter?
Overview of the Issue
When attempting to build the following
debian-11
template with Packer, found here in the Microsoft/MSLab-templates repository.The build will get stuck on
Waiting for SSH to become available...
due to it attempting to retrieve thedebian-11-preseed.cfg
from the incorrect IP address.The plugin currently obtains the IP address used to specify the URL to the
debian-11-preseed.cfg
file here in the following PowerShell command.Reproduction Steps
When running the following part of the PowerShell script on my host machine, I get the following output.
The second part of the command pipes this output to
Select-Object -First 1
so it returns first object return by the prior command.However, there are two network adapters on my system configured by Hyper-V.
You can see that because selects the
vEthernet (nat)
adapter it then goes on to use the incorrect IP address in the preseed URL.packer build
logTyped boot command showing the incorrect preseed URL
Stuck on blue screen
After it gets stuck you can connect to the virtual machine and press
Alt + F2
to access a terminal.Debugging with
ping
andwget
Then run the following commands to ascertain that the virtual machine cannot connect to the host using the
vEthernet (nat)
adapter's IP address (172.26.160.1
), only when thevEthernet (Default Switch)
adapter's IP address (172.26.208.1
) is used can thepreseed.cfg
file be retrieved by the virtual machine.Plugin and Packer version
Simplified Packer Buildfile
https://github.com/microsoft/MSLab-templates/tree/48109b672dad7599d62c9771d22ce5711274e04e/templates/debian-11/debian-11.pkr.hcl
Operating system and Environment details
Log Fragments and crash.log files
packer build
log with$env:PACKER_LOG=1