Trying to build a Linux VM on Hyper-V with Packer 1.4.4 fails with the following error message
==> hyperv-vmcx: Creating build directory...
==> hyperv-vmcx: Creating switch 'VistaLAN' if required...
==> hyperv-vmcx: switch 'VistaLAN' already exists. Will not delete on cleanup...
==> hyperv-vmcx: Cloning virtual machine...
==> hyperv-vmcx: Enabling Integration Service...
==> hyperv-vmcx: Skipping mounting Integration Services Setup Disk...
==> hyperv-vmcx: Mounting secondary DVD images...
==> hyperv-vmcx: Configuring vlan...
==> hyperv-vmcx: Determine Host IP for HyperV machine...
==> hyperv-vmcx: Error getting host adapter ip address: PowerShell error: At C:\vcs\tfs\vista\devinfrastructure\Resource-Artefacts.Storage\build\temp\powershell017775038.ps1:4 char:20
==> hyperv-vmcx: + if ($HostVMAdapter){
==> hyperv-vmcx: + ~
==> hyperv-vmcx: Missing closing '}' in statement block or type definition.
==> hyperv-vmcx: + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
==> hyperv-vmcx: + FullyQualifiedErrorId : MissingEndCurlyBrace
==> hyperv-vmcx: Unregistering and deleting virtual machine...
==> hyperv-vmcx: Deleting output directory...
==> hyperv-vmcx: Deleting build directory...
Build 'hyperv-vmcx' errored: Error getting host adapter ip address: PowerShell error: At C:\vcs\tfs\vista\devinfrastructure\Resource-Artefacts.Storage\build\temp\powershell017775038.ps1:4 char:20
+ if ($HostVMAdapter){
+ ~
Missing closing '}' in statement block or type definition.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndCurlyBrace
==> Some builds didn't complete successfully and had errors:
--> hyperv-vmcx: Error getting host adapter ip address: PowerShell error: At C:\vcs\tfs\vista\devinfrastructure\Resource-Artefacts.Storage\build\temp\powershell017775038.ps1:4 char:20
+ if ($HostVMAdapter){
+ ~
Missing closing '}' in statement block or type definition.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndCurlyBrace
==> Builds finished but no artifacts were created.
1.4.4. Windows version
{
"variables": {
"admin_username": "admin",
"admin_password": "admin",
"dir_http_user": "c:/temp/packer/http",
"dir_temp": "c:/temp",
"dir_vm_import": "c:/temp/packer/vm-import",
"vm_switch_name": "switch1",
},
"builders": [
{
"boot_wait": "5s",
"boot_command": [],
"clone_from_vmcx_path": "{{ user `dir_vm_import` }}",
"communicator": "ssh",
"enable_dynamic_memory": false,
"enable_mac_spoofing": false,
"enable_secure_boot": true,
"enable_virtualization_extensions": false,
"generation": 2,
"guest_additions_mode": "disable",
"headless": true,
"http_directory": "{{ user `dir_http_user` }}",
"http_port_min": 8150,
"http_port_max": 8160,
"memory": "1024",
"output_directory": "{{ user `dir_temp` }}/myvm",
"secure_boot_template": "MicrosoftUEFICertificateAuthority",
"ssh_password": "{{user `admin_password`}}",
"ssh_timeout": "4h",
"ssh_username": "{{user `admin_username`}}",
"switch_name": "{{user `vm_switch_name`}}",
"type": "hyperv-vmcx",
"vm_name": "myvm"
}
],
"provisioners": [ ]
}
Windows 10
Version 1903
OS build 18362.387
Executing the same packer config on the same machine with Packer 1.4.3 works so it looks like a regression in 1.4.4
Same error here on Windows server 2019, this was working with packer 1.4.3
Hi everyone,
Just to increase the details about this error, I'm facing the same issue and observe some other information in the log: Found available port: 8036 on IP: 0.0.0.0
, so it may have some related to IP management as well.
Context Packer utilization:
Description I'm building the latest production version of CoreOS in Hyper-v
Packer version: 1.4.4
CoreOs version: 2191.5.0
Hyperv Version: 10.0.17763.1
Windows Version: 10 Pro 17763.737
Sorry about that everyone! I'll get this fixed up ASAP and we'll release a nightly build once it's patched.
The nightly release should solve this issue: https://github.com/hashicorp/packer/releases/tag/nightly
Sorry again for this regression. I'll be leaving this issue open for other people to find so that we minimize duplicate reports, but this is fixed on the master branch and the fix will be in the 1.5.0 release.
Hi @SwampDragons
I tried build my template using the nightly release and this doesn't work.
Before build the template now, was needed to set all network configurations to Private, disable Firewall authentications and start WinRM manually:
1- Enable-PSRemoting -SkipNetworkProfileCheck -Force
2- Set-NetConnectionProfile -NetworkCategory Private
3- winrm quickconfig
Even with these configurations, still getting the timeout error when packer tries to connect in the IP using wget http. See the attaching
packer_error.txt
log.
It seems to be a issue related with CoreOs.
See: https://sysnetdevops.com/2018/01/02/getting-packer-working-with-coreos-on-hyper-v/
Can you please share a gist with a basic template that works on v1.4.3 and fails on 1.4.4?
It doesn't work in this other versions for me as well.
I tried using 1.4.3, 1.4.4 and 1.4.5(All return errors)
Template:
{
"description": "CoreOS image for a VirtualBox platform.",
"builders": [{
"type": "hyperv-iso",
"iso_url": "https://stable.release.core-os.net/amd64-usr/current/coreos_production_iso_image.iso",
"iso_checksum": "5d41fe61404f298a87f303d766b84d3b",
"iso_checksum_type": "md5",
"ssh_username": "packer",
"ssh_password": "packer",
"memory": 3000,
"ssh_timeout" : "10m",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
}]
}
Okay, then your problem isn't the same as the original issue on this thread, which is specifically a regression from 1.4.3.
I notice that your template doesn't include any boot_command or ignition file, which is why SSH can't connect. You need to provide an ignition file that sets up SSH so that Packer can connect.
If you're struggling to get Packer working for the first time, I'd recommend reaching out to the mailing list or community forum for help, since there are a lot more people reading those lists than the Github issue tracker.
Thanks -- I had the same issue building on hyper-v with 1.4.4 and the nightly build did resolve it.
worked!
For those who don't know how to use the nightly build, simply type where packer
and then rename the existing one to something else and then rename the one you downloaded to packer.exe and copy to the same folder.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
The nightly release should solve this issue: https://github.com/hashicorp/packer/releases/tag/nightly
Sorry again for this regression. I'll be leaving this issue open for other people to find so that we minimize duplicate reports, but this is fixed on the master branch and the fix will be in the 1.5.0 release.