hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.14k stars 3.33k forks source link

source hyperv-iso doesn't work since packer v1.9.x #12468

Closed ThomasPatzig closed 1 year ago

ThomasPatzig commented 1 year ago

Community Note

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Version

packer --version 1.9.1

Environment

Win10 22H2

Scenario

try to build a hyper-v image from win 10 ISO

Steps to Reproduce

packer build -force -on-error=ask PackerTemplate.pkr.hcl

have defined HCL:

source "hyperv-iso" "main-windows" {
...}
build {
  sources = ["source.hyperv-iso.main-windows"]
..
}

Expected Result

VM creation starts (has worked with packer 1.8.7)

Actual Result

Error: Unknown source type hyperv-iso

  on PackerTemplate.pkr.hcl line 27:
  (source code not available)

known builders: [parallels-iso azure-arm parallels-pvm azure-dtl virtualbox-ovf
vmware-iso docker amazon-instance googlecompute vsphere-iso amazon-ebsvolume
virtualbox-iso vmware-vmx amazon-chroot amazon-ebssurrogate azure-chroot
virtualbox-vm vsphere-clone file vagrant qemu null amazon-ebs]

Set the env var PACKER_LOG=1 for maximum log detail.

packer build -force -on-error=ask PackerTemplate.pkr.hcl
2023/06/14 11:29:52 [INFO] Packer version: 1.9.1 [go1.20.4 windows amd64]
2023/06/14 11:29:52 [TRACE] discovering plugins in C:\ProgramData\chocolatey\lib\packer\tools
2023/06/14 11:29:52 [TRACE] discovering plugins in C:\Users\<<replaced>>\AppData\Roaming\packer.d\plugins
2023/06/14 11:29:52 [TRACE] discovering plugins in .
2023/06/14 11:29:52 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/06/14 11:29:52 [INFO] PACKER_CONFIG env var set; attempting to open config file: C:\Users\<<replaced>>\AppData\Roaming\packer.config
2023/06/14 11:29:52 [WARN] Config file doesn't exist: C:\Users\<<replaced>>\AppData\Roaming\packer.config
2023/06/14 11:29:52 [INFO] Setting cache directory: d:\VMs\VM-04CAC833AAD3\packer_cache
e: cannot determine if process is in background: Process background check error: not implemented yet

Error: Unknown source type hyperv-iso
  on PackerTemplate.pkr.hcl line 27:

  (source code not available)
  on PackerTemplate.pkr.hcl line 27:

  (source code not available)
known builders: [null vsphere-clone amazon-ebssurrogate vmware-vmx googlecompute

parallels-pvm vagrant azure-chroot azure-dtl docker virtualbox-iso virtualbox-vm
known builders: [null vsphere-clone amazon-ebssurrogate vmware-vmx googlecompute
file amazon-ebsvolume amazon-chroot amazon-instance vmware-iso virtualbox-ovf
parallels-pvm vagrant azure-chroot azure-dtl docker virtualbox-iso virtualbox-vm
parallels-iso amazon-ebs azure-arm qemu vsphere-iso]
file amazon-ebsvolume amazon-chroot amazon-instance vmware-iso virtualbox-ovf

parallels-iso amazon-ebs azure-arm qemu vsphere-iso]
2023/06/14 11:29:52 [INFO] (telemetry) Finalizing.

2023/06/14 11:29:52 [WARN] (telemetry) Error finalizing report. This is safe to ignore. Post "https://checkpoint-api.hashicorp.com/v1/telemetry/packer": dial tcp: lookup checkpoint-api.hashicorp.com: no such host

2023/06/14 11:29:52 [ERR] Checkpoint error: Get "https://checkpoint-api.hashicorp.com/v1/check/packer?arch=amd64&os=windows&signature=92a863a2-902b-d9d2-e1f5-611c05fc775b&version=1.9.1": dial tcp: lookup checkpoint-api.hashicorp.com: no such host
2023/06/14 11:29:52 waiting for all plugin processes to complete...
ThomasPatzig commented 1 year ago

have also opened here: https://github.com/chef/bento/issues/1509

VishnuJin commented 1 year ago

this is a +1 from me

nywilken commented 1 year ago

Hi there folks, I can see how this is a bit of surprise. Apologies if this change was not called out enough in the release email and CHANGELOG.

Starting with Packer 1.9.0 the community maintained components, such as hyperv-iso, were removed from the Packer binary. These external plugin components are released independently of Packer core and can be installed directly by the user. This is the recommended approach from this point forward, and is part of the Packer Plugin split work started in v1.7.0.

To Install the latest available Hyper V plugin you can use the following command before running a Packer build.

packer plugins install github.com/hashicorp/hyperv 

Since this appears to be related to the chef/bento project I recommend asking the maintainers to add a required plugins block to their HCL2 configuration files. Pinging @Stromweld for visibility.

This way the correct plugins version can be automatically installed by running packer init

packer {
  required_plugins {
    hyperv = {
      version = ">= 1.1.0"
      source  = "github.com/hashicorp/hyperv"
    }
  }
}

Please refer to the CHANGELOG for the full list of community-maintained plugins that are no longer bundled with Packer.

This is not a bug but I am keeping it open for folks to refer to and to allow the chef/bento team time to chime in.

nywilken commented 1 year ago

I took a look at the chef/bento repo and it appears that the project is already using the rquired_plugins block for pinning plugin versions. Please run packer init before trying to run packer build -force -on-error=ask PackerTemplate.pkr.hcl to install all the necessary plugins used within within the project templates.

I'm going to close this issue as there is nothing to be done on the chef/bento side.

ThomasPatzig commented 1 year ago

plugin install can fail because of proxy

packer plugins install github.com/hashicorp/hyperv
1 error occurred:
        * Get "https://api.github.com/repos/hashicorp/packer-plugin-hyperv/git/matching-refs/tags": dial tcp: lookup api.github.com: no such host
set HTTP_PROXY=http://127.0.0.1:3128/
set HTTPS_PROXY=http://127.0.0.1:3128/

-> works

packer plugins install github.com/hashicorp/hyperv
Installed plugin github.com/hashicorp/hyperv v1.1.0 in "C:/Users/<<replaced>>/AppData/Roaming/packer.d/plugins/github.com/hashicorp/hyperv/packer-plugin-hyperv_v1.1.0_x5.0_windows_amd64.exe"

to check that plugin is already there:

packer plugins installed
C:\Users\<<replaced>>\AppData\Roaming\packer.d\plugins\github.com\hashicorp\hyperv\packer-plugin-hyperv_v1.1.0_x5.0_windows_amd64.exe
ThomasPatzig commented 1 year ago

I don't like the separate plugin install because of:

packer plugins install github.com/hashicorp/hyperv 1 error occurred:

...and it does not support proxy with auth...

is it really need from your side to unbundle hyperv from packer?

github-actions[bot] commented 1 year ago

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.