srb3 / terraform-libvirt-domain

MIT License
1 stars 2 forks source link

Multiple VMs / can't find storage-pool #9

Open tuxpeople opened 2 years ago

tuxpeople commented 2 years ago

For this, I'm currently unable to provide a PR. Because I'm not completely understand it.

I tried to create 3 VMs.

1st attempt:

module "my_pool" {
  source = "srb3/pool/libvirt"
  name   = "default"
  path   = "/data/virt/vms/pools/kvm_tf_pool"
}

module "my-domain" {
  count      = 3
  source     = "srb3/domain/libvirt"
  os_name    = "ubuntu"
  hostname   = "tf-kvm-test-${count.index}"
  os_version = "20.10"
  memory     = 2048
  pool       = "default"
  vcpu       = 2
  autostart  = true
  network    = "${var.location}-tf"
  user_cloudinit = templatefile("./templates/cloud_init.cfg", {
    hostname       = "tf-kvm-test-${count.index}"
    user           = "ansible"
    ssh_public_key = chomp(file("~/.ssh/id_rsa.pub"))
  })
}

Terraform doesn't like it: Bildschirmfoto 2021-10-04 um 14 34 53

So I thought, Terraform doesn't like to use the same pool for multiple VMs. So this was my 2nd attempt:

module "my_pool" {
  count  = 3
  source = "srb3/pool/libvirt"
  name   = "default-${count.index}"
  path   = "/data/virt/vms/pools/kvm_tf_pool-${count.index}"
}

module "my-domain" {
  count      = 3
  source     = "srb3/domain/libvirt"
  os_name    = "ubuntu"
  hostname   = "tf-kvm-test-${count.index}"
  os_version = "20.10"
  memory     = 2048
  pool       = "default-${count.index}"
  vcpu       = 2
  autostart  = true
  network    = "${var.location}-tf"
  user_cloudinit = templatefile("./templates/cloud_init.cfg", {
    hostname       = "tf-kvm-test-${count.index}"
    user           = "ansible"
    ssh_public_key = chomp(file("~/.ssh/id_rsa.pub"))
  })
}

The funny thing: No word about the first pool, but errors regarding the 2nd and 3rd one: Bildschirmfoto 2021-10-04 um 14 36 51

Which I cannot understand, the pools have been created:

[root@lab2 ~]# virsh pool-list
 Name                 Status     Automatischer Start
-------------------------------------------
 data                 Aktiv      ja
 default-0            Aktiv      ja
 default-1            Aktiv      ja
 default-2            Aktiv      ja

This is not related to #7, as I have that fix in place. Just before I spend hours of debugging, is it supposed to be working with count?

include commented 1 year ago

same here - help appreciated