dzintars / infra

Roles and various notes to set up my workstation. WIP. Some of the content can be out of date and incorrect.
2 stars 0 forks source link

Terraform stage is looking for a custom provider in the wrong place #37

Open dzintars opened 3 years ago

dzintars commented 3 years ago
[0mCould not retrieve the list of available versions for provider
dmacvicar/libvirt: provider registry registry.terraform.io does not have a
provider named registry.terraform.io/dmacvicar/libvirt
dzintars commented 3 years ago
dzintars commented 3 years ago

So... this silly stage does the job for now. For sure need to refactor it, but as PoC it's fine. I need to place the terraform-provider-libvirt vinary in the booth locations.

    stage('1 Install dmacvicar/libvirt plugin') {
      steps {
          git 'https://github.com/dmacvicar/terraform-provider-libvirt.git'
          sh 'ls -lah'
          script {
            try {
              sh 'make'
            } catch (err) {
              echo err.getMessage()
            }
          }
          sh 'ls -lah'
          sh 'mkdir ~/.terraform.d/plugins'
          sh 'cp terraform-provider-libvirt ~/.terraform.d/plugins/'
          sh 'mkdir -p ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64'
          sh 'cp terraform-provider-libvirt ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64'
      }
    }

P.S. BTW this stage does not work in the rootless Jenkins container even if make and go are installed. For now i just left it aside and installed Jenkins in the VM.

Also it it important that every terraform module contains

terraform {
  required_version = ">= 0.14.4"
  required_providers {
    libvirt = {
      source  = "dmacvicar/libvirt"
      version = "~>0.6.3"
    }
  }
}

and

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

stanzas. And... not only the child modules, but also in the root module. Can't remember the issue i read about this workaround. If will find, will make a refference later.