Then I placed the binary, which is called “terraform-provider-libvirt-v0.8.3” in this folder ~/.terraform.d/plugins/
Then in my main.tf file, I did:
terraform {
required_providers {
libvirt = {
version = “0.8.3”
}
}
}
Then I tried to run terraform init command, but it still tries to pull the libvirt provider from internet which doesn’t work. I also tried to specify plugin path on the cli on the terraform init command, but it did not work either. Do you have any other ideas what I can try?
You can suppress some of the validation etc. with -backend=false.
There are also some things you can do with provider cache if you want to avoid having to re-download every time. Since it looks like you’re already trying to do that, I’d double-check that you have all the paths set correctly (via env vars, or defaults, or command line flags). You may also be able to get more info on why it’s not working as you expect by running init with more verbosity.
Chatted with a co-worker, and only way I could make this work was like this:
Download the binary to the local directory ~/.terraform.d/plugins/registry.terraform.io/local/libvirt/0.8.3/darwin_arm64/terraform-provider-libvirt
Then when I run terraform init it is successful (note I do not have an available environment where I can further test the libvirt plugin so this is tested only through terraform init).
terraform init
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/hcp versions matching "~> 0.104.0"...
- Finding local/libvirt versions matching "0.8.3"...
- Installing hashicorp/hcp v0.104.0...
- Installed hashicorp/hcp v0.104.0 (signed by HashiCorp)
- Installing local/libvirt v0.8.3...
- Installed local/libvirt v0.8.3 (unauthenticated)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
╷
│ Warning: Incomplete lock file information for providers
│
│ Due to your customized provider installation methods, Terraform was forced to calculate lock
│ file checksums locally for the following providers:
│ - local/libvirt
│
│ The current .terraform.lock.hcl file only includes checksums for darwin_arm64, so Terraform
│ running on another platform will fail to install these providers.
│
│ To calculate additional checksums for another platform, run:
│ terraform providers lock -platform=linux_amd64
│ (where linux_amd64 is the platform to generate)
╵
Terraform has been successfully initialized!
I threw in another provider that was downloaded from the registry just to see the difference.