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.05k stars 3.32k forks source link

QEMU support in Packer 1.10.1 is broken (at least in the package from the offical HashiCorp Ubuntu repository) #12830

Open dreibh opened 7 months ago

dreibh commented 7 months ago

I just installed the latest Packer 1.10.1-1 from the offical HashiCorp Ubuntu repository (https://developer.hashicorp.com/packer/install#Linux) and tried the QEMU example JSON (https://developer.hashicorp.com/packer/integrations/hashicorp/qemu/latest/components/builder/qemu):

$ sudo apt-get install packer=1.10.1-1
...
packer build x.json
Error: Failed to initialize build "qemu"

The builder qemu is unknown by Packer, and is likely part of a plugin that is
not installed.
You may find the needed plugin along with installation instructions documented
on the Packer integrations page.

https://developer.hashicorp.com/packer/integrations?filter=qemu

However, the QEMU example works fine when downgrading to 1.9.5-1:

$ sudo apt-get install packer=1.9.5-1
...
$ packer build x.json
Warning: Bundled plugins used

This template relies on the use of plugins bundled into the Packer binary.
The practice of bundling external plugins into Packer will be removed in an
upcoming version.

To remove this warning and ensure builds keep working you can install these
external plugins with the 'packer plugins install' command

* packer plugins install github.com/hashicorp/qemu

Alternatively, if you upgrade your templates to HCL2, you can use 'packer init'
with a 'required_plugins' block to automatically install external plugins.

You can try HCL2 by running 'packer hcl2_upgrade
/home/dreibh/src/nornet/vmimage-builder-scripts/x.json'

qemu: output will be in this color.

==> qemu: Retrieving ISO
==> qemu: Trying http://mirror.raystedman.net/centos/6/isos/x86_64/CentOS-6.9-x86_64-minimal.iso
==> qemu: Trying http://mirror.raystedman.net/centos/6/isos/x86_64/CentOS-6.9-x86_64-minimal.iso?checksum=md5%3Aaf4a1640c0c6f348c6c41f1ea9e192a2
...

That is, the QEMU support got broken in the 1.10.1-1 release, at least for the Ubuntu package.

dreibh commented 7 months ago

I also noticed that APT downloads 16.4 MiB for the 1.10.1-1 package, while it downloads 24.3 MiB for 1.9.5-1. May be the QEMU support is not built into the latest Ubuntu package?

dreibh commented 7 months ago

The same issue also applies to the vsphere-iso builder, i.e. the Ubuntu package 1.10.1-1 also seems to not contain the vSphere builder. Again, a downgrade to 1.9.5-1 works fine.

dreibh commented 7 months ago

The Ubuntu package seems to not include "packer-plugin-qemu" or "packer-plugin-vsphere", which are now separate Git repositories. It seems the package building needs to be updated to also include the plugins.

nywilken commented 7 months ago

Hi @dreibh thanks for reaching out, with the removal of bundled plugins from Packer 1.10.0 plugins previously shipped in the Packer binary must now be installed separately. Unfortunately, this is not something that can be codified in JSON templates, which is why you are seeing this issue.

Have you tried executing the suggested command within the error message packer plugins install ...?

To get past this initial issue you want to run the following command to install the latest version for the QEMU plugin.

packer plugins install github.com/hashicorp/qemu

For external plugins such as QEMU or vSphere, you will find instructions on the integration portal for installing the plugin using the packer plugins install command for JSON users and packer init for HCL2 template users.