dmacvicar / terraform-provider-libvirt

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

Error finding providers after making changes - hashicorp/libvirt #1026

Open geoff-sheldon opened 10 months ago

geoff-sheldon commented 10 months ago

System Information

Linux distribution

Manjaro Linux

Terraform version

Terraform v1.5.3
on linux_amd64
+ provider registry.terraform.io/dmacvicar/libvirt v0.7.1

Your version of Terraform is out of date! The latest version
is 1.5.4. You can update by downloading from https://www.terraform.io/downloads.html

Provider and libvirt versions

0.7.1, specified in module

Description of Issue/Question

Setup

(Please provide the full main.tf file for reproducing the issue (Be sure to remove sensitive information)

terraform {
    required_providers {
        libvirt = {
            source = "registry.terraform.io/dmacvicar/libvirt"
        }
    }
}

provider "libvirt" {
    # configuration options
    uri = "qemu:///system"
    # alias = "server2"
    # uri = "qemu+ssh://root@192.168.100.10/system"
}

# Defining VM Volume
resource "libvirt_volume" "centos7-qcow2" {
  name = "centos7.qcow2"
  pool = "default" # List storage pools using virsh pool-list
  source = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2"
  #source = "./CentOS-7-x86_64-GenericCloud.qcow2"
  format = "qcow2"
}

# Define KVM domain to create
resource "libvirt_domain" "centos7" {
  name   = "centos7"
  memory = "2048"
  vcpu   = 2

  network_interface {
    network_name = "default" # List networks with virsh net-list
  }

  disk {
    volume_id = "${libvirt_volume.centos7-qcow2.id}"
  }

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

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

resource "libvert_network" "default" {
    name = "default"
}

# Output Server IP
output "ip" {
  value = "${libvirt_domain.centos7.network_interface.0.addresses.0}"
}
``

### Steps to Reproduce Issue

Run `terraform init`, get the following:

Initializing the backend...

Initializing provider plugins...

Any Terraform command returns this. I ran terraform providers and got this:


Providers required by configuration:
.
├── provider[registry.terraform.io/dmacvicar/libvirt]
└── provider[registry.terraform.io/hashicorp/libvert]

Providers required by state:

    provider[registry.terraform.io/dmacvicar/libvirt]

That's the only module in this directory, but for some reason Terraform thinks the configuration specifies that a hashicorp/libvert source is being specified. I have no idea - nowhere in the code do I specify this. What's interesting is that this apparently isn't coming from the state, it's actually getting resolved from the code somehow.

michaelbeaumont commented 10 months ago

Looks like a typo in your resource:

resource "libvert_network" "default" {
geoff-sheldon commented 10 months ago

Ahh, my apologies. Thank you for pointing that out!

On Sun, Aug 6, 2023, 1:52 AM Mike Beaumont @.***> wrote:

Looks like a typo in your resource:

resource "libvert_network" "default" {

— Reply to this email directly, view it on GitHub https://github.com/dmacvicar/terraform-provider-libvirt/issues/1026#issuecomment-1666779429, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALSHYD36LSOKMX2BUKU7PDLXT5LODANCNFSM6AAAAAA3FU3D4I . You are receiving this because you authored the thread.Message ID: @.***>