2

It seems like the libvirt provider only takes pre-defined cloud images. I create my own base qcow2 image that is local to the hypervisor and wish to use it as source file with terraform libvirtd.

Is this doable?

Config using cloud image:

resource "libvirt_volume" "terraform-test" {
    name = "terraform-test.qcow2"
    pool = "default"
    source = "https://cloud.debian.org/images/cloud/buster/daily/20200324-210/debian-10-nocloud-amd64-daily-20200324-210.qcow2"
    format = "qcow2"

Instead, I'd like to use a local file in the hypervisor like so:

resource "libvirt_volume" "terraform-test" {
    name = "terraform-test.qcow2"
    pool = "default"
    source = "/var/lib/libvirt/images/base-image.qcow2"
    format = "qcow2"



Error: Error while determining image type for /var/lib/libvirt/images/base-image.qcow2: Error while opening /var/lib/libvirt/images/base-image.qcow2: open /var/lib/libvirt/images/base-image.qcow2: no such file or directory
vmx1987
  • 21
  • 2

2 Answers2

4

You will have to specify it like this:

resource "libvirt_volume" "terraform-test" {
  name = "terraform-test.qcow2"
  pool = "default"
  source = "file:///var/lib/libvirt/images/base-image.qcow2"
  format = "qcow2"

And remember that the Terraform will look for the image on the controller node (from where the Terraform is running).

0

Maybe the problem is that you are using the pool and the local path,do something like this:

resource "libvirt_volume" "kube-node-1" {
  name = "kube-node-1"
  pool = "default"
  source = "base-image"
  format = "qcow2"
  full_clone = true
}
c4f4t0r
  • 5,149
  • 3
  • 28
  • 41