packer-builder-arm icon indicating copy to clipboard operation
packer-builder-arm copied to clipboard

Support for Automatic Plugins

Open cdecoux opened this issue 3 years ago • 11 comments

Packer added support for pulling in external plugins via a required_plugins block and packer init You can see the reference docs here: https://www.packer.io/plugins#installing-plugins

There's an existing issue out - #100 - to rename this repo to fit the naming convention. I attempted that in my fork, but turns out there's more stuff needed. I followed the docs for plugin development and referenced a scaffolding repo provided by Hashicorp to get a general idea of what needed to change. I made shortcuts to get a working example, so definitely could be improved upon to make properly updated, but hopefully this PR can be a good starting point for that.

I've got my fork built, released, and get a successful attempt:

Code:

packer {
  required_plugins {
    arm = {
      source = "github.com/cdecoux/builder-arm"
      version = "1.0.0"
    }
  }
}

Command:

packer init .

The added workflow is only triggered if a proper tag is pushed. The tag must be a valid Semantic Version preceded with a v.

As of now, I have not tested actually using it. Nor have I tested this with the legacy usage. I'm just now learning about Packer ATM. Those should be done before merging this PR.

cdecoux avatar Feb 16 '22 08:02 cdecoux

Hey @cdecoux,

thanks a lot for this PR. I'll check it out in a few days!

mkaczanowski avatar Feb 16 '22 08:02 mkaczanowski

@cdecoux any idea where to put the binary during CI (no download from release page in that case) so that packer finds it without packer init. (That should be possible independent from the repo rename topic)

dbast avatar Oct 20 '22 16:10 dbast

hm... the logs tell, that is actually detected [DEBUG] Discovered plugin: arm = /home/runner/work/packer-builder-arm/packer-builder-arm/packer-builder-arm... but then fails with

Error: Failed to initialize build "arm"

error initializing builder 'arm': plugin exited before we could connect

dbast avatar Oct 20 '22 16:10 dbast

@cdecoux Finished your PR... fixed the lint findings, added versioning so that make plugin-check is happy (also now runs via the CI test flow).

Also did a release in my renamed fork of the repothat can be used for testing via the packer plugin init process:

  • by adding the plugin to a $board.pkr.hcl

    packer {
       required_plugins {
         arm = {
           version = ">=v1.1.0"
           source  = "github.com/dbast/arm"
         }
      }
    }
    
  • calling packer init $board.pkr.hcl the plugin gets downloaded and can be used

I removed GPG signing for the time being (not required / afaik not checked by packer) and also disabled the non Linux binary builds (they are not useable).

Important next step before the merge is renaming the repo to the pattern packer-plugin-* and aligning the binary in this PR to be named the same.

dbast avatar Nov 02 '22 18:11 dbast

@cdecoux Finished your PR... fixed the lint findings, added versioning so that make plugin-check is happy (also now runs via the CI test flow).

Awesome work! If the test workflow runs on every version release, then it looks like that can be removed from the gorelease. I had just uncommented it until I saw the test workflow, so I'll go ahead and re-remove it.

cdecoux avatar Nov 02 '22 18:11 cdecoux

Hi guys, thanks for this PR!, I'm glad to see this change!

goldyfruit avatar Jan 12 '23 13:01 goldyfruit

Synced changes and resolved conflicts. Are we able to get this merged after renaming the repo to packer-plugin-arm?

(and FYI, renaming the repo should automatically redirect https://github.com/mkaczanowski/packer-builder-arm to https://github.com/mkaczanowski/packer-plugin-arm)

cdecoux avatar Sep 23 '23 03:09 cdecoux

I thought I try your repo but I get the following error when building an image.

    Pwnagotchi Torch 64bit.arm.opi-pwnagotchi: mounting sysfs with: [mount -t sysfs sysfs /tmp/1445813868/sys]
==> Pwnagotchi Torch 64bit.arm.opi-pwnagotchi: Failed to find binfmt_misc for /usr/bin/qemu-aarch64-static under /proc/sys/fs/binfmt_misc

jayofelony avatar Oct 31 '23 12:10 jayofelony

@jayofelony which OS are you using on the host?

shanduur avatar Oct 31 '23 13:10 shanduur

I'm using WSL Ubuntu under Windows 11. Trying to build an image for Raspios Bullseye 64bit. When I use the main repo it works like it should.

jayofelony avatar Oct 31 '23 13:10 jayofelony

Today I installed Ubuntu desktop on my laptop, and the same error is given there. But when I build packer-builder-arm from main repo and put the executable in builder folder all works normal.

jayofelony avatar Nov 15 '23 14:11 jayofelony