hashicorp / packer-plugin-hyperv

Packer plugin for Hyper-V Builder
https://www.packer.io/docs/builders/hyperv
Mozilla Public License 2.0
19 stars 24 forks source link

IP corrupted with "The following Msvm_KvpExchangeDataItem.Name keys are deprecated" #134

Closed othrayte closed 3 months ago

othrayte commented 3 months ago

Whilst the issue is that WinRM can't connect I felt this was probably the more correct place to report as it looks like an issue with getting the IP for the HyperV VM.

Overview of the Issue

WinRM fails to connect. Debug output shows the error message "The following Msvm_KvpExchangeDataItem.Name keys are deprecated: NetworkAddressIPv4, NetworkAddressIPv6, RDPAddressIPv4, and RDPAddressIPv6. Please configure guest IP addresses using Msvm_GuestNetworkAdapterConfiguration." replaces the IP address after second reboot. (the after the first reboot it actually gets what looks like the correct IP, but the firewall rules aren't setup yet.

Plugin and Packer version

From packer version

Packer version: 1.11.2 [go1.21.12 windows amd64] Plugin version: 1.1.3

Simplified Packer Buildfile

https://gist.github.com/othrayte/39c621f4a0dabb0be160339e618a8ab0

I'll try to simplify this down tomorrow, bit late atm

Operating system and Environment details

Windows 11 Enterprise 23H2

Log Fragments and crash.log files

[INFO] Attempting WinRM connection...
[DEBUG] connecting to remote shell using WinRM
[ERROR] connection error: unknown error Post "https://10.1.1.107:5986/wsman": dial tcp 10.1.1.107:5986: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
[ERROR] WinRM connection err: unknown error Post "https://10.1.1.107:5986/wsman": dial tcp 10.1.1.107:5986: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
[INFO] Attempting WinRM connection...
[DEBUG] connecting to remote shell using WinRM
[ERROR] connection error: impossible to create http request parse "https://The following Msvm_KvpExchangeDataItem.Name keys are deprecated: NetworkAddressIPv4, NetworkAddressIPv6, RDPAddressIPv4, and RDPAddressIPv6. Please configure guest IP addresses using Msvm_GuestNetworkAdapterConfiguration.:5986/wsman": invalid character " " in host name
[ERROR] WinRM connection err: impossible to create http request parse "https://The following Msvm_KvpExchangeDataItem.Name keys are deprecated: NetworkAddressIPv4, NetworkAddressIPv6, RDPAddressIPv4, and RDPAddressIPv6. Please configure guest IP addresses using Msvm_GuestNetworkAdapterConfiguration.:5986/wsman": invalid character " " in host name
othrayte commented 3 months ago

Note: In reducing the packer buildfile down it looks like the issue might not be with this plugin. Testing more now.

Update: the real issue was not this error and was a configuration issue see next comment.

othrayte commented 3 months ago

So it turns out the issue was just that the winrm_username was wrong and the lines with the error message where the IP should be were not actually preventing it working.

After the attempts with the error message IP address, there were subsequent attempts to connect which didn't have that issues packer/plugins seem to get past that. In attempting to reproduce the issue today I have not seen the error message in the IP again but I did find that it works if I use the correct username (which for my current setup is Administrator).