Score:0

Terraform Libvirt - How to use local qcow2 file

tr flag

i try to provision some nodes for a kubernetes cluster based on kvm and debian. I want to use the Debian 11 Genericcloud Image and clound-init to initialize it. So i put the debian baseimge to /var/lib/libvirt/images/templates on the remote machine, where kvm runs. I worked thorugh some tutorials and serverfault post and the say, I should handle it like this in my code:

resource "libvirt_volume" "diskimages" {
  count = var.instance_count
  name = "${var.instance_name}-${count.index}.qcow2"
  pool = libvirt_pool.diskimage_pool.name
  source = var.baseimage
  format = "qcow2"
}

where baseimage = "/var/lib/libvirt/images/templates/debian-11-genericcloud-amd64.qcow2". But when i execute this i get the following error:

Error: error while determining image type for /var/lib/libvirt/images/templates/debian-11-genericcloud-amd64.qcow2: error while opening /var/lib/libvirt/images/templates/debian-11-genericcloud-amd64.qcow2: open /var/lib/libvirt/images/templates/debian-11-genericcloud-amd64.qcow2: no such file or directory
│ 
│   with libvirt_volume.diskimages[4],
│   on libvirt.tf line 25, in resource "libvirt_volume" "diskimages":
│   25: resource "libvirt_volume" "diskimages" {

Same when i try the solution from this serverfault post. Then my code looks like this:

# create .qcow2 image for vm
resource "libvirt_volume" "diskimages" {
  count = var.instance_count
  name = "${var.instance_name}-${count.index}.qcow2"
  pool = libvirt_pool.diskimage_pool.name
  source = "file///var/lib/libvirt/images/templates/debian-11-genericcloud-amd64.qcow2"
  format = "qcow2"
}

and i get the same error.

Does anyone have a clue whats going wrong here? Thanks in advance

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.