dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.6k stars 458 forks source link

Can't find storage pool default #840

Closed Dr4s1l closed 3 years ago

Dr4s1l commented 3 years ago

Still got this issue even if the pool exist, also recreate it on different path still got issue

Host Config:

Fedora 31

Terraform Version Report (0.14)

Libvirt version 5.6.0

terraform-provider-libvirt plugin version (stable binary)

Setup

#
# worker nodes
#

resource "libvirt_volume" "worker_image" {
  count  = local.workers
  name   = "worker-${count.index + 1}"
  pool   = "default"
  source = "https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"
  format = "qcow2"
}

resource "libvirt_volume" "worker" {
  count          = local.workers
  name           = "volume-${count.index + 1}"
  base_volume_id = element(libvirt_volume.worker_image.*.id, count.index)
  size           = var.worker_root_size
}

resource "libvirt_cloudinit_disk" "commoninit" {
  count     = local.workers
  name      = "k8s-worker-${count.index + 1}-commoninit.iso"
  pool      = "default"
  user_data = element(data.template_file.user_data.*.rendered, count.index + 1)
}

data "template_file" "user_data" {
  count    = local.workers
  template = file("${path.module}/kubernetes_cloudinit.cfg")
  vars = {
    hostname    = "k8s-worker${count.index + 1}"
    public_key  = var.public_key
    k8s_version = var.k8s_version
    k8s_minor   = var.k8s_minor
  }
}

resource "libvirt_domain" "worker" {
  count  = local.workers
  name   = "k8s-worker${count.index + 1}"
  memory = var.worker_mem
  vcpu   = var.worker_cpu

  disk {
    volume_id = element(libvirt_volume.worker.*.id, count.index + 1)
  }

  network_interface {
    network_name = "default"
  }

  cloudinit = element(libvirt_cloudinit_disk.commoninit.*.id, count.index + 1)

  console {
    type        = "pty"
    target_port = "0"
    target_type = "serial"
  }

  graphics {
    type        = "spice"
    listen_type = "address"
    autoport    = "true"
  }

  autostart = var.enable_autostart
}

terraform {
  required_version = ">= 0.14"
}

Also :

 Nom       État    Démarrage automatique
------------------------------------------
 default   actif   yes

And the provider declaration :

terraform {
  required_providers {
    libvirt = {
      # According to new terraform 0.13 hacky plugin path
      source  = "hashicorp/libvirt"
      version = "1.0.0"
    }
  }
}

provider "libvirt" {
  uri = "qemu:///system"
}

Current behavior :

module.k8s.libvirt_volume.worker_image[1]: Creating...
module.k8s.libvirt_cloudinit_disk.commoninit[1]: Creating...
module.k8s.libvirt_volume.worker_image[0]: Creating...
module.k8s.libvirt_cloudinit_disk.commoninit[0]: Creating...

Error: can't find storage pool 'default'

  on k8s/main.tf line 5, in resource "libvirt_volume" "worker_image":
   5: resource "libvirt_volume" "worker_image" {

Error: can't find storage pool 'default'

  on k8s/main.tf line 5, in resource "libvirt_volume" "worker_image":
   5: resource "libvirt_volume" "worker_image" {

Error: can't find storage pool 'default'

  on k8s/main.tf line 20, in resource "libvirt_cloudinit_disk" "commoninit":
  20: resource "libvirt_cloudinit_disk" "commoninit" {

Error: can't find storage pool 'default'

  on k8s/main.tf line 20, in resource "libvirt_cloudinit_disk" "commoninit":
  20: resource "libvirt_cloudinit_disk" "commoninit" {

Expected behavior

Access the default storage pool using terraform libvirt provider

Originally posted by @Dr4s1l in https://github.com/dmacvicar/terraform-provider-libvirt/issues/446#issuecomment-785347214

Dr4s1l commented 3 years ago

Also got trace log :

2021/02/24 21:34:06 [DEBUG] EvalApply: ProviderMeta config value set
2021/02/24 21:34:06 [DEBUG] module.k8s.libvirt_cloudinit_disk.commoninit[0]: applying the planned Create change
2021/02/24 21:34:06 [TRACE] GRPCProvider: ApplyResourceChange
2021-02-24T21:34:06.625+0100 [DEBUG] plugin.terraform-provider-libvirt: 2021/02/24 21:34:06 ISO contents created
2021-02-24T21:34:06.625+0100 [DEBUG] plugin.terraform-provider-libvirt: 2021/02/24 21:34:06 [DEBUG] Locked "default"
2021-02-24T21:34:06.625+0100 [DEBUG] plugin.terraform-provider-libvirt: 2021/02/24 21:34:06 [DEBUG] Unlocking "default"
2021-02-24T21:34:06.625+0100 [DEBUG] plugin.terraform-provider-libvirt: 2021/02/24 21:34:06 [DEBUG] Unlocked "default"
2021-02-24T21:34:06.625+0100 [DEBUG] plugin.terraform-provider-libvirt: 2021/02/24 21:34:06 About to execute cmd: /usr/bin/mkisofs -output /tmp/cloudinit993970904/k8s-worker-2-commoninit.iso -volid cidata -joliet -rock /tmp/cloudinit993970904/user-data /tmp/cloudinit993970904/meta-data /tmp/cloudinit993970904/network-config
2021/02/24 21:34:06 [DEBUG] module.k8s.libvirt_volume.worker_image[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: can't find storage pool 'default'
Dr4s1l commented 3 years ago

User permission issue

digitalgopnik commented 3 years ago

@Dr4s1l What was the exact issue? Can you give a bit more information on your fix? :)

busti commented 3 months ago

@digitalgopnik I had the same problem. Creating the storage pool in virtmanager instead of using virsh resolved the problem.