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

The "Using the provider" section of README.md is wrong for recent versions of terraform #858

Closed SCDealy closed 3 years ago

SCDealy commented 3 years ago

System Information

Linux distribution

Ubuntu 18.04 LTS but issue applies to all distros

Terraform version

1.0.0

Provider and libvirt versions

0.6.3/linux_amd64/terraform-provider-libvirt b01ffe296c84d0c15ccc6625bfde1597f01cc053 Compiled against library: libvirt 4.0.0 Using library: libvirt 4.0.0 Running hypervisor: QEMU 2.11.1 Running against daemon: 4.0.0


Checklist

Description of Issue/Question

If one follows the instructions in the "Using the provider" section of README.md, using the latest version of terraform (1.0.0 though this presumably applies to any version 0.13 or later), the provider will not be found.

The needed changes to make the README.md example work can be found by following the link in the table of contents for "Migrating to terraform v13". Unfortunately for new users, they are not "migrating to" anything, so this document appears irrelevant and they can waste a lot of time figuring out on their own what the problem is. As a new user to both terraform and the libvirt provider, this killed about six hours (though now I know the basics of how to debug terraform, both the older and new provider implementation, search paths, and a host of other likely useful things that I would have preferred to learn later).

Setup

Steps to Reproduce Issue

Follow "Using the provider" instructions / example in terraform-provider-libvirt README.md

Additional information:

vmorris commented 3 years ago

It may not be correct, but I struggled through this and found a way forward yesterday: https://github.com/dmacvicar/terraform-provider-libvirt/issues/838#issuecomment-864451291

SCDealy commented 3 years ago

To make it easier for people who get this far, below are the three different ways you can add the provider that worked for me with terraform 1.0.0

terraform {
   required_version = ">= 1.0"
   required_providers {
      # This is works, using this location:
      #
      #    ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt
      #
      # which is the recommendation for terraform-provider-libvirt when
      # migrating to Terraform 0.13 as given here:
      #
      #    https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/docs/migration-13.md
      # 
      libvirt = {
         source = "dmacvicar/libvirt"
         version = "0.6.3"
      }

      # This works with the provider in a zip file placed here:
      #
      #    ~/.terraform.d/plugins/localdomain/provider/libvirt/terraform-provider-libvirt_0.6.3_linux_amd64.zip
      #
      #libvirt = {
      #   source = "localdomain/provider/libvirt"
      #   version = "0.6.3"
      #}

      # This works with the provider placed here:
      #
      # ~/.terraform.d/plugins/localdomain2/provider/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt
      #
      #libvirt = {
      #   source = "localdomain2/provider/libvirt"
      #   version = "0.6.3"
      #}
   }
}

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

resource "libvirt_domain" "terraform_test" {
  name = "terraform_test"
}
dmacvicar commented 3 years ago

From now (master) on the official way to install the provider is from the terraform provider registry. Give it a try to what is described in the pre-release:

https://github.com/dmacvicar/terraform-provider-libvirt/releases/tag/v0.6.9-pre3