boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
678 stars 46 forks source link

Using the libvirt provider, not in the Terraform registry throws `Failed to query available provider packages` #70

Closed larssb closed 3 years ago

larssb commented 3 years ago

Checklist

My Environment

Software Version
Operating System CentOS 8
Terraform v0.13.5
Terraspace v0.5.10
Ruby ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

Expected Behaviour

I'm expecting/hoping to be able to use this libvirt provider with Terraspace. For now it can only be used as a local provider until the project have uploaded it to the HashiCorp Terraform registry.

Current Behavior

When executing terrspace up STACK_NAME Terraspace throws the following error:

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider
hashicorp/libvirt: provider registry.terraform.io/hashicorp/libvirt was not
found in any of the search locations

- /root/terraform-providers/

Re-producing

  1. execute terraspace new project WHATEVER_NAME
  2. execute terraspace new stack test-k3s-cluster
  3. execute terraspace new module k3s-cluster

the files relative to the stack: test-k3s-cluster should contain

the files relative to the module: k3s-cluster should contain

Terraspace/Terraform config files should contain:

The project structure is:

.
├── app
│   ├── modules
│   │   └── k3s-cluster
│   │       ├── conf
│   │       │   ├── network-config.yaml
│   │       │   └── user-data.yaml
│   │       ├── main.tf
│   │       ├── outputs.tf
│   │       └── variables.tf
│   └── stacks
│       └── test-k3s-cluster
│           ├── main.tf
│           ├── outputs.tf
│           └── variables.tf
├── config
│   ├── app.rb
│   └── terraform
│       ├── backend.tf
│       ├── provider.tf
│       └── terraform.tf
├── Gemfile
├── Gemfile.lock
├── README.md
└── Terrafile
  1. execute terraspace up test-k3s-cluster and the err should be seen after some time

Logs

The below is the Terraspace run log

Initializing modules...
- k3s-cluster in ../../modules/k3s-cluster

Initializing the backend...

Successfully configured the backend "remote"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding local/providers/libvirt versions matching "~> 0.6.3"...
- Finding latest version of hashicorp/libvirt...
- Installing local/providers/libvirt v0.6.3...
- Installed local/providers/libvirt v0.6.3 (unauthenticated)
Initializing modules...
- k3s-cluster in ../../modules/k3s-cluster

Initializing the backend...

Successfully configured the backend "remote"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding local/providers/libvirt versions matching "~> 0.6.3"...
- Finding latest version of hashicorp/libvirt...
- Using local/providers/libvirt v0.6.3 from the shared cache directory

Other comments

Building .terraspace-cache/us-east-1/dev/stacks/test-k3s-cluster
INFO: You're missing AWS credentials. Only local services are currently available
INFO: You're missing AWS credentials. Only local services are currently available
Built in .terraspace-cache/us-east-1/dev/stacks/test-k3s-cluster
Syncing to Terraform Cloud: test-k3s-cluster => hospites-dev
** Also likely the culprit to the region mishap described above

Looking forward to all the help I can get. Any help is appreciated.

Thank you very much

larssb commented 3 years ago

And btw. The libvirt provider IS installed and works in a Terragrunt/Terraform setting.

tongueroo commented 3 years ago

Oh I see. Bummer. I was incorrect about terraspace working with only on-prem resources only. Just tested it. A few notes:

Note: Also tested with TFC and AWS also this morning and that works: https://gist.github.com/tongueroo/6f20cf014406021fc9ebf3f7f1bc139b

larssb commented 3 years ago

I'm no Ruby expert. But, I really like this framework and the way it tries to keep things DRY. However, maybe you could give me some pointers on where to start? It sounds like the tasks are:

  1. Get rid of the default use of AWS
  2. Get an on-prem plugin started

Does that sound about right?

Thank you

tongueroo commented 3 years ago

Sure. Thanks for the kind words. That sounds about right.

RE: plugin

Note, there's a plugin generator https://terraspace.cloud/reference/terraspace-new-plugin/ Created it after built 2 plugins. It's probably does not have the up-to-date interface anymore, but thinking it'll help. Lot of the terraspace plugin interfaces are based on dogfooding. The interfaces will probably change based on that dogfooding. Found that's usually the best way to build them. So there are some cavaets. It's also decent amount of effort. Of course, no sweat either way 👍