terraform-provider-libvirt icon indicating copy to clipboard operation
terraform-provider-libvirt copied to clipboard

strange validation on local machine for local libvirt-sock

Open liyihuang opened this issue 1 year ago • 3 comments
trafficstars

System Information

Mac or Linux as the client

Linux distribution

Ubuntu 22.04

Terraform version

terraform version
Terraform v1.9.3-dev
on linux_amd64
+ provider registry.terraform.io/dmacvicar/libvirt v0.7.6
+ provider registry.terraform.io/equinix/equinix v2.3.0
+ provider registry.terraform.io/hashicorp/local v2.5.1
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/tls v4.0.5
+ provider registry.terraform.io/tenstad/remote v0.1.2
  • [x ] Is it a bug or something that does not work as expected? Please make sure you fill the version information below:

Description of Issue/Question

Setup

 module "infra" {                                                                                                          
   source           = "git::https://github.com/isovalent/terraform-equinix-infra"                                          
   api_key          = var.api_key                                                                                          
   infra_name       = var.infra_name                                                                                       
   k8s_cluster_name = "liyi-ocp"                                                                                           
 }    

Steps to Reproduce Issue

I wrote a module called terraform-equinix-infra(https://github.com/isovalent/terraform-equinix-infra/tree/main). the module is pretty straightforward. It will spin up a baremetal server at https://deploy.equinix.com/, install qemu and a few VM on top of it. However, I found when I run the terraform apply on the laptop that doesn't have the libvirt on it, it will throw out the error saying

dial unix /var/run/libvirt/libvirt-sock: connect: no such file or directory                   
│                                                                                                                          
│   with module.infra.provider["registry.terraform.io/dmacvicar/libvirt"],                                                 
│   on .terraform/modules/infra/providers.tf line 5, in provider "libvirt":                                                
│  

My question is why the provider wants to validate if there is a local unix socket at all? I have to install some packages like to get it working.

apt --yes install --no-install-recommends libguestfs-tools libvirt-daemon-system qemu-system

I'm trying to understand if I missed anything or I didn't configure it correctly

liyihuang avatar Jul 28 '24 19:07 liyihuang

It is not clear from description but I think what you want to do is to connect to remote libvirt instance. In that case, you do not need anything libvirt installed on your laptop. There are plenty of ways to communicate with remote libvirt daemon. Look here and here.

scabala avatar Sep 02 '24 19:09 scabala

@scabala thanks for replying and I was on vacation in last 2 weeks. I'm using the ssh as this code shows. https://github.com/isovalent/terraform-equinix-infra/blob/main/providers.tf but it will validate my local libvirt

liyihuang avatar Sep 16 '24 14:09 liyihuang

There might be some conflict when using code directly and when using it from a module. I cannot find the exact issue - there's one already in issue tracker - but long story short, you need to specify exactly the same uri in module and outside of it.

scabala avatar Sep 17 '24 20:09 scabala

you can avoid this issue by applying terraform apply in order

liyihuang avatar Sep 20 '25 12:09 liyihuang