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
  • 1
    please, show your code – c4f4t0r Mar 27 at 11:05
  • code added. Thanks! – vmx1987 Mar 27 at 14:56
  • did you get any error when you run terraform apply? – c4f4t0r Mar 27 at 15:11
  • I placed the error message on top instead. I'm thinking that it may be looking elsewhere possibly where I run terraform from in a different system. – vmx1987 Mar 27 at 15:24

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.