Open Cengizeren opened 3 years ago
I've had better results with ~/.terraform.d/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt_v0.6.3
instead. (I am using 0.6.3.)
Hi,
I moved the related file to "~/.terraform.d/plugins" directory but the result is still the same. I want to ask a question, my goal is to provision VM in my remote KVM host, do I have to install KVM on the server where I run Terraform to do this job?
Hi all, have the same trouble with v0.6.3 built from source with go1.13.15 (because of 1.13 in go.mod)
running provider from CLI gives the following
.terraform/providers/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt:
/lib64/libvirt.so.0: version `LIBVIRT_4.10.0' not found (required by .terraform/providers/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt)
OS is Centos 7 with latest updates libvirt packages:
libvirt-4.5.0-36.el7_9.3.x86_64
libvirt-devel-4.5.0-36.el7_9.3.x86_64
Thanks in advance.
@Cengizeren, it's absolutely unnecessary to have KVM installed on your local machine. The ssh opened at KVM host and permissions to run libvirt for the user you connecting as are the only condition as far as i undestand.
@youdzinn After you said "I built from the source code", I tried to build from the source code and it works for me. When I downloaded this project from the releases page, I encountered an error as I said before. This is very interesting. But I have another error, maybe you have an idea.
I am using Ubuntu qcow2 image and cloudinit.iso files in my VM provisioning with Terraform. But Terraform threw the following error:
Error: Error defining libvirt domain: virError(Code=1, Domain=20, Message='internal error unknown disk type 'volume'')
@Cengizeren it's hard to tell what's exactly causing this error, could you show the snippet with volume definition, please? And what is the OS you running tf from, what is libvirt package version?
@youdzinn You are right, I am sharing some information about my system.
Terraform Volume Snippet
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.6.2"
}
}
}
variable "VM_COUNT" {
default = 1
type = number
}
variable "VM_HOSTNAME" {
default = "vm"
type = string
}
variable "VM_IMG_URL" {
default = "https://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img"
# default = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2"
type = string
}
variable "VM_IMG_FORMAT" {
default = "qcow2"
type = string
}
provider "libvirt" {
alias = "remotehost"
uri = "qemu+ssh://abc@xxx.xxx.xxx.xxx/system"
}
resource "libvirt_pool" "vm" {
name = "${var.VM_HOSTNAME}_pool"
type = "dir"
path = "/tmp/terraform-provider-libvirt-pool-ubuntu"
}
resource "libvirt_volume" "vm" {
count = var.VM_COUNT
name = "${var.VM_HOSTNAME}-${count.index}_volume.${var.VM_IMG_FORMAT}"
pool = libvirt_pool.vm.name
source = var.VM_IMG_URL
format = var.VM_IMG_FORMAT
}
OS Versions: Terraform is working on Ubuntu 18.04.5 LTS Bionic and Terraform wants to connect an RHEL 6.10 KVM server.
Libvirt Version on KVM Server Compiled against library: libvirt 0.10.2 Using library: libvirt 0.10.2 Using API: QEMU 0.10.2 Running hypervisor: QEMU 0.12.1
Maybe the problem was caused by the libvirt version, it looks too old.
I have the same problem.
[root@server terraform]# pwd
/root/terraform
[root@server terraform]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@server terraform]# virsh version --daemon
Compiled against library: libvirt 4.5.0
Using library: libvirt 4.5.0
Gebruikte API: QEMU 4.5.0
Draaiende hypervisor: QEMU 1.5.3
Running against daemon: 4.5.0
[root@server terraform]# terraform -v
Terraform v0.14.7
+ provider registry.terraform.io/dmacvicar/libvirt v0.6.3
[root@server terraform]# ls -lash
totaal 12K
0 drwxr-xr-x. 2 root root 51 3 mrt 22:01 .
4,0K dr-xr-x---. 18 root root 4,0K 3 mrt 21:52 ..
4,0K -rw-r--r--. 1 root root 204 3 mrt 21:58 libvirt.tf
4,0K -rw-r--r--. 1 root root 283 3 mrt 21:58 .terraform.lock.hcl
[root@server terraform]# cat libvirt.tf
terraform {
required_version = ">= 0.14"
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.6.3"
}
}
}
provider "libvirt" {
uri = "qemu:///system"
}
[root@server terraform]# terraform init
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of dmacvicar/libvirt from the dependency lock file
- Installing dmacvicar/libvirt v0.6.3...
- Installed dmacvicar/libvirt v0.6.3 (unauthenticated)
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
[root@server terraform]# terraform plan
Error: Could not load plugin
Plugin reinitialization required. Please run "terraform init".
Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.
Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".
Failed to instantiate provider "registry.terraform.io/dmacvicar/libvirt" to
obtain schema: Unrecognized remote plugin message:
This usually means that the plugin is either invalid or simply
needs to be recompiled to support the latest protocol.
[root@server terraform]#
[root@server terraform]# find ~/.terraform.d/
/root/.terraform.d/
/root/.terraform.d/checkpoint_signature
/root/.terraform.d/plugins
/root/.terraform.d/plugins/terraform-provider-libvirt
/root/.terraform.d/plugins/registry.terraform.io
/root/.terraform.d/plugins/registry.terraform.io/terraform-provider-libvirt
/root/.terraform.d/checkpoint_cache
[root@server terraform]# find ~/.local/
/root/.local/
/root/.local/share
/root/.local/share/terraform
/root/.local/share/terraform/plugins
/root/.local/share/terraform/plugins/registry.terraform.io
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt
[root@server terraform]#
@pablochacin I also tried with v0.13.6 and still got this.
Building from source and moving the executable to the directory and using the name @bnevis-i suggested using terraform v0.13.6 worked for me.
Building from source fixed it for me as well.
Hi I have built from source code but still same problem. can you point me source code where i can find it.
@abhishek-tyagi87 Seems like a number of things could be the problem. Let us know what versions of terraform and terraform-provider-libvirt you are using as well as the error output.
@Xachman I am using terraform version 0.13.0 and libvert provider version is 0.6.2, I was getting below error during terraform plan ,my terraform init was successful."Terraform Error: Failed to instantiate provider "registry.terraform.io/dmacvicar/libvirt" to obtain schema: Unrecognized remote plugin message"
@abhishek-tyagi87 im using 0.6.3 of terraform-provider-libvirt.
@Xachman can you please let me know from where I can get libvert 0.6.3 working binary and main.yalm which is working in your environment. One observation I face when I am trying 0.6.2 binary with terraform which is installed as binary on virtual machine ,it was not throwing this error,but when I am using with same binary in terraform containers that containers I made using dockerfile ,at that time was facing this error
@abhishek-tyagi87 I'm not sure what you mean by libvert 0.6.3 we are talking specifically about this project terraform-provider-libvert.
Have you followed the instructions at https://github.com/dmacvicar/terraform-provider-libvirt#building-the-provider to build from source? I think I just used the current master branch and that worked.
The binaries included in the release should work it maybe @dmacvicar can comment on what's up here since many are going to run into this issue as they update.
I've had better results with
~/.terraform.d/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt_v0.6.3
instead. (I am using 0.6.3.)
Also this is important.
I think it's well explained here: https://www.terraform.io/docs/language/providers/requirements.html#in-house-providers
We could just standardize and create the following directory structure: ~/.terraform.d/plugins/github.com/macvicar/libvirt/0.6.3/linux_amd64
, then, place the binary there and use it as follows:
terraform {
required_providers {
libvirt = {
source = "github.com/macvicar/libvirt"
version = ">= 0.6.3"
}
}
}
provider "libvirt" {
uri = "qemu:///system"
}
resource "libvirt_domain" "terraform_test" {
name = "terraform_test"
}
At least it's closer to reality, no?
A variation we could do is just use source = "local/macvicar/libvirt"
and create the directories accordingly. I dunno; it's the crystal/go/podman influence in me. ;D
Confirmed, this works:
terraform {
required_providers {
libvirt = {
source = "local/macvicar/libvirt"
version = ">= 0.6.3"
}
}
}
provider "libvirt" {
uri = "qemu:///system"
}
resource "libvirt_domain" "terraform_test" {
name = "terraform_test"
}
If you put your plugin at: .terraform.d/plugins/local/macvicar/libvirt/0.6.3/linux_amd64
.
I was able to make this work today:
terraform {
required_providers {
libvirt = {
source = "multani/libvirt"
version = "0.6.3-1+4"
}
}
}
provider "libvirt" {
uri = "qemu:///system"
}
Hi everybody. Thanks a lot for the feedback. :pray:
I am not going to invest much time debugging these problems. Most of the work is happening on the pure-go
branch, where we get rid of libvirt client side. :factory_worker:
This means:
If anyone wants to improve the situation, I welcome helping us testing the pure-go branch so that we can realease as soon as possible.
I tried this in two different systems. First System is Centos 7.8, the other system is Ubuntu 18.04.5 LTS Bionic. My Terraform version is v0.13.4.
I used the following provider information in my main.tf:
Also, I downloaded the "terraform-provider-libvirt" version 0.6.2 to "~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.2/linux_amd64" directory. I saw this directory in some examples.
When I run the "terraform init" command, there was no error. After that, when I run the "terraform apply" command, I encountered the following error:
How can I get rid of this problem, what is the solution?