toowoxx / terraform-provider-packer

Terraform Provider for HashiCorp Packer
Mozilla Public License 2.0
32 stars 7 forks source link

Failed to run packer build: No plugin installed for ... #12

Closed karelorigin closed 2 years ago

karelorigin commented 2 years ago

Not sure what suddenly caused this issue to appear, perhaps I updated Packer or the provider (or both). Seems like Packer no longer ships certain builder plugins by default. Currently using Terraform 1.2.1, Packer 1.8.1, and Provider 0.11.0.

│ Error: Failed to run packer build
│ 
│   with module.foo.packer_image.bar,
│   on .terraform/modules/foo/modules/bar/main.tf line 24, in resource "packer_image" "bar":
│   24: resource "packer_image" "bar" {
│ 
│ could not run packer command; output: Error: no plugin installed for
│ github.com/hashicorp/scaleway 1.0.3
│ 
│ Did you run packer init for this project ?
│ 
│ 
│ : exit status 1

It could be fixed by manually initializing all packer plugins, but the code is no longer portable, which causes issues with my GitHub Action workflows.

simaotwx commented 2 years ago

Hi @karelorigin This looks a bit weird to me. Note that the installed Packer version is not relevant for the provider as the provider uses the embedded Packer, not the installed one.

I'll have to take a look at this. Maybe an update to Packer 1.8.1 will be enough as we're currently still on 1.8.0.

karelorigin commented 2 years ago

@simaotwx, I see. Does the provider call itself? Not sure if an update to Packer will work, but it's worth trying.

simaotwx commented 2 years ago

@karelorigin Yes, it does call itself. Packer is included, mainly to allow use on Terraform Cloud and to prevent users from using an unsupported version.

karelorigin commented 2 years ago

Have you been able to reproduce it @simaotwx? The latest versions of terraform and the provider on TF Cloud (or on your local machine if you haven't executed packer init yet) should be able to reproduce this issue

simaotwx commented 2 years ago

@karelorigin I will try to reproduce it soon. Packer init is run here by the provider.

I have released a new version with Packer 1.8.1 included, maybe that helps?

simaotwx commented 2 years ago

I use this Provider version 0.12.0 to build on Azure via TFC and I can't reproduce the issue.

karelorigin commented 2 years ago

@simaotwx, what Terraform version are you using on TF Cloud? It doesn't automatically upgrade and it definitely worked on 1.1.7 for me, my TF Cloud workspace now runs on 1.2.1.

Thanks for updating the embedded packer. I'll test it later today, but I'm starting to suspect that it's somehow a terraform issue.

simaotwx commented 2 years ago

@karelorigin I'm using 1.1.9. Maybe 1.2.x introduced a regression or the plugin framework needs to be upgraded. I will check on this.

simaotwx commented 2 years ago

I changed the version to 1.2.2 and started a Plan & Apply run which has already successfully produced images. I need a 100% reproducible example that is easy to set up and run.

simaotwx commented 2 years ago

image

karelorigin commented 2 years ago

Thanks for checking. I had the exact same scenario but instead identical terraform code suddenly stopped being able to build images. It does work locally as I mentioned earlier. I'll try again tonight, perhaps it was just a fluke in TF Cloud.

simaotwx commented 2 years ago

Might have just been a fluke since nothing was changed before it stopped working. Looking forward to your report.

simaotwx commented 2 years ago

Please let me know if it was just a fluke

simaotwx commented 2 years ago

There's been no activity for this issue for over a month so I will close this issue. Feel free to reopen if the issue persists and you have more information for us.

karelorigin commented 2 years ago

Sorry for the late response. When I originally opened this issue, I had already tried various times on different days. Even though this error no longer appears, the TF Cloud run just stops with no additional information.

These are the last few lines in the TF Cloud output:

2022-07-21T09:44:54.958Z [INFO]  provider.terraform-provider-scaleway_v2.2.2: 2022/07/21 09:44:54 [DEBUG] [DEBUG] GET https://api.scaleway.com/rdb/v1/regions/nl-ams/instances/23419bf9-6c5c-4786-afa8-6e3750c8ebac: timestamp=2022-07-21T09:44:54.847Z
module.hashistack.module.bastion[0].packer_image.bastion: Still creating... [3m22s elapsed]
module.hashistack.module.nomad-client[0].packer_image.nomad: Still creating... [3m22s elapsed]
module.hashistack.module.consul[0].packer_image.consul: Still creating... [3m23s elapsed]
module.hashistack.module.nomad[0].packer_image.nomad: Still creating... [3m23s elapsed]
module.hashistack.module.vault[0].packer_image.vault: Still creating... [3m23s elapsed]

Keep in mind that Terraform runs in debug mode here, so anything interesting should've been logged. Doesn't appear that it saved any previously created resources to state either, so it could be a Terraform Cloud issue. Not sure why this is happening though. I even tried to recreate the workspace but same problem.

simaotwx commented 2 years ago

@karelorigin Thanks for your feedback. Have you tried contacting TF Cloud support? They usually are pretty quick and competent. Maybe they can give a little insight into what is happening here. I could imagine that creating 5 images at the same time could have an effect on this. The provider should be able to handle that, though.

The log should contain some error message with all the stack trace output etc. explaining what happened in case of a crash. This does not seem to be present here so I assume it's got to be something else.

karelorigin commented 2 years ago

@simaotwx, looks like it might indeed be a TF Cloud issue. Thing is that I didn't make any changes and it used to work fine. The entire setup just stopped working overnight.

That's good to know, I'll contact TF Cloud support and see what they have to say. :)