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

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

Open
dzintars opened this issue Jan 10, 2021 · 2 comments
Open
Assignees

Comments

@dzintars
Copy link
Owner

[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 dzintars self-assigned this Jan 10, 2021
@dzintars
Copy link
Owner Author

dzintars commented Jan 10, 2021

    1. Official third-party providers location is ~/.terraform.d/plugins docs
    1. Other place where terraform init places "official" plugins is .terraform/plugins/<OS>_<ARCH> docs
    1. Less documented place to place custom plugins is ~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64 (can't find the source). Be careful about the correct path structure.

@dzintars
Copy link
Owner Author

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.

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

1 participant