Packer build fails with Error: Unknown source

Looking for a bit of help with packer… The issue I’m having is that Packer doesn’t recognize the source I’m using:
In a file called sources.pkr.hcl:

source "arm-image" "k8s" {
  iso_url = "https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2021-05-28/2021-05-07-raspios-buster-arm64-lite.zip"
  iso_checksum = "sha256:868cca691a75e4280c878eb6944d95e9789fa5f4bbce2c84060d4c39d057a042"
  output_filename = "../output-arm-image/k8s.img"
  target_image_size = 3*1024*1024*1024
  qemu_binary = "qemu-aarch64-static"
}

In the main build file, build.pkr.hcl

build {
  sources = [
    "source.arm-image.k8s"
  ]
...
}

Error is: Error: Unknown source arm-image.k8s

The command I’m running is just “packer build build.pkr.hcl”. These files are in the same directory. Ideas?

on line 0:
(source code not available)

Known:

Are you including some sort of external builder? Otherwise arm-image isn’t a built in type. You have to use one of the types that packer knows or have a plugin that adds that function in.

From the rest of the source I imagine you want the source to be “qemu”, not “arm-image”.

1 Like

Ah I realized I missed an important part. There’s also a plugins file:

packer {
  required_plugins {
    arm-image = {
      version = ">= 0.2.5"
      source  = "github.com/solo-io/arm-image"
    }
  }
}

@aram

Btw, this is in a docker container as described in the plugin. I was able to run init from inside the container and got:

Installed plugin github.com/solo-io/arm-image v0.2.5 in "/root/.config/packer/plugins/github.com/solo-io/arm-image/packer-plugin-arm-image_v0.2.5_x5.0_linux_amd64"

however, still getting the same error as before.

I am getting the same issue here.

I tried to follow these official examples, but Packer can’t find the source block:

$ packer validate build.ubuntu.pkr.hcl 
Error: Unknown source vsphere-iso.base-ubuntu-amd64

  on  line 0:
  (source code not available)

Known: []

Here is a short version of my code:

# build.ubuntu.pkr.hcl

build {
    name = "ubuntu"

    source "source.vsphere-iso.base-ubuntu-amd64" {}
}

# source.vsphere-iso.pkr.hcl

source "vsphere-iso" "base-ubuntu-amd64" {}

Is there an undocumented, magic command to make Packer work with split files ?

EDIT: Found the answer in HCL Templates documentation. The magic command is:

packer validate .