toowoxx / terraform-provider-packer

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

Error: The following plugins are required, but not installed #18

Closed kaiyuanlim closed 2 weeks ago

kaiyuanlim commented 1 month ago

Describe the bug I got an error when running terraform apply.

2024-07-16T07:06:21.4589401Z │ Output: Error: Missing plugins
2024-07-16T07:06:21.4589615Z │ 
2024-07-16T07:06:21.4589871Z │ The following plugins are required, but not installed:
2024-07-16T07:06:21.4590104Z │ 
2024-07-16T07:06:21.4590338Z │ * github.com/hashicorp/azure ~> 1
2024-07-16T07:06:21.4590554Z │ 
2024-07-16T07:06:21.4590800Z │ Did you run packer init for this project ?
2024-07-16T07:06:21.4591020Z │ 
2024-07-16T07:06:21.4591208Z │ 
2024-07-16T07:06:21.4591393Z │ 
2024-07-16T07:06:21.4591595Z │ Error: exit status 1

To Reproduce Steps to reproduce the behavior:

Using packer.pkr.hcl with content

packer {
  required_plugins {
    azure = {
      source  = "github.com/hashicorp/azure"
      version = "~> 1"
    }
  }
}

Expected behavior Terraform packer should run packer init before packer build

Additional information (please complete the following information):

Additional context

simaotwx commented 1 month ago

Thanks for reporting. The provider does run packer init here: https://github.com/toowoxx/terraform-provider-packer/blob/main/provider/resource_packer_image.go#L219

I'll have to take a closer look at this.

kaiyuanlim commented 1 month ago

Okay, that is strange.

This might help.


resource "packer_image" "azdo" {
  directory = "${path.module}/packer"

  variables = {
    rg_name       = data.azurerm_resource_group.azdo.name
    rg_region     = data.azurerm_resource_group.azdo.location
    vm_size       = local.vm_size
    gallery_name  = azurerm_shared_image.azdo_ubuntu_22_04.gallery_name
    image_name    = azurerm_shared_image.azdo_ubuntu_22_04.name
    image_version = var.image_version
    disk_size     = local.disk_size
    azdo_username = local.azdo_username
    vnet_name     = local.name
  }

  triggers = {
    folder_hash = sha1(join("", [for f in fileset("packer", "*") : filesha1("${path.module}/packer/${f}")]))
  }
}

#And inside my "packer" folder

ls
agent.pkr.hcl       config          github.com      packer.pkr.hcl      scripts         variables.pkr.hcl
´´´
kaiyuanlim commented 1 month ago

Any updates?

simaotwx commented 1 month ago

Not sure what the issue is, I will have to investigate further. One thing I noticed Is that you can use this data source for your folder trigger: https://registry.terraform.io/providers/toowoxx/packer/latest/docs/data-sources/files

kaiyuanlim commented 1 month ago

Not sure what the issue is, I will have to investigate further. One thing I noticed Is that you can use this data source for your folder trigger: https://registry.terraform.io/providers/toowoxx/packer/latest/docs/data-sources/files

Yes but i am already using "directory" in "packer_image" and i added a trigger.

The issue is that it does not seems to download and install the required plugins when i ran terraform apply.

simaotwx commented 2 weeks ago

I'm unable to reproduce this at the HEAD of the branch. When the new version is released, please test again and let me know.

kaiyuanlim commented 2 weeks ago

And when will that be? Thank you in advanced.

simaotwx commented 2 weeks ago

And when will that be?

I'll try to get it out today.

simaotwx commented 2 weeks ago

I'm going to close this issue because I can't reproduce it on the latest version. If the issue persists please let me know.