Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Automatic Plugins #172

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

cdecoux
Copy link

@cdecoux cdecoux commented Feb 16, 2022

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.

@mkaczanowski
Copy link
Owner

Hey @cdecoux,

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

.goreleaser.yml Outdated
# consumption by Packer.io. To include a separate docs.zip uncomment the following command.
#- make ci-release-docs
# Check plugin compatibility with required version of the Packer SDK
# - make plugin-check
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scaffolding repo (https://github.com/hashicorp/packer-plugin-scaffolding) originally had this make plugin-check enabled and required a GNUmakefile from the same repo. I tried that myself and had a few errors, so I've bypassed it for now.

@dbast
Copy link
Collaborator

dbast commented Oct 20, 2022

@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
Copy link
Collaborator

dbast commented Oct 20, 2022

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
Copy link
Collaborator

dbast commented Nov 2, 2022

@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.

@cdecoux
Copy link
Author

cdecoux commented Nov 2, 2022

@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.

@goldyfruit
Copy link

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

@@ -21,3 +21,4 @@
.packer_plugins
packer_cache
packer-builder-arm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If changing name of the package, should this be kept?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If changing name of the package, should this be kept?

packer-builder-arm will not be required anymore I guess.

@cdecoux
Copy link
Author

cdecoux commented Sep 23, 2023

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)

@jayofelony
Copy link

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

@shanduur
Copy link

shanduur commented Oct 31, 2023

@jayofelony which OS are you using on the host?

@jayofelony
Copy link

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
Copy link

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.

michalfita added a commit to michalfita/packer-plugin-cross that referenced this pull request Dec 26, 2023
We apply the obvious aiming at rename and let this fork live its own life.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants