Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
geoff-sheldon opened this issue Aug 6, 2023 · 2 comments
Open

Comments

@geoff-sheldon
Copy link

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

  • [X ] Is it a bug or something that does not work as expected? Please make sure you fill the version information below:

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...

  • Reusing previous version of dmacvicar/libvirt from the dependency lock file
  • Finding latest version of hashicorp/libvert...
  • Using previously-installed dmacvicar/libvirt v0.7.1

    │ Error: Failed to query available provider packages

    │ Could not retrieve the list of available versions for provider hashicorp/libvert: provider registry registry.terraform.io does not have a provider named
    │ registry.terraform.io/hashicorp/libvert

    │ All modules should specify their required_providers so that external consumers will get the correct providers when using a module. To see which modules are currently depending on
    │ hashicorp/libvert, run the following command:
    │ terraform providers

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
Copy link
Collaborator

Looks like a typo in your resource:

resource "libvert_network" "default" {

@geoff-sheldon
Copy link
Author

geoff-sheldon commented Aug 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants