Terraform为什么看不到我的手动安装的提供程序?

时间:2020-05-04 20:02:29

标签: terraform rancher rke

我正在尝试将RKE provider安装为Rancher AWS quickstart的一部分。 Terraform documentation说,插件应安装在~/.terraform.d/plugins处。 RKE文档说该插件应该安装在~/terraform.d/plugins/<your_platform>上。

试图调和冲突的信息,我尝试将二进制文件复制到以下所有位置,但是Terraform从未看到它们中的任何一个:

~/.terraform.d/plugins/terraform-provider-rke
~/.terraform.d/plugins/rke
~/.terraform.d/plugins/darwin_amd64/terraform-provider-rke
~/.terraform.d/plugins/darwin_amd64/rke
~/terraform.d/plugins/terraform-provider-rke
~/terraform.d/plugins/rke
~/terraform.d/plugins/darwin_amd64/terraform-provider-rke
~/terraform.d/plugins/darwin_amd64/rke

在每种情况下,当我运行terraform init时,都会出现以下错误:

Provider "rke" not available for installation.

A provider named "rke" could not be found in the Terraform Registry.

This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.

In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
    terraform.d/plugins/darwin_amd64

Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".


Error: no provider exists with the given name

作为最后的选择,我可以使用terraform init -plugin-dir=<something>。但是随后Terraform看不到任何自动下载的插件,因此我必须手动安装所有内容。

是否缺少一些路径变量,或者我没有遵循的其他命名约定?

2 个答案:

答案 0 :(得分:6)

事实证明该错误消息并没有说明全部。 Terraform正在查找提供程序,但它认为这不是一个足够新的版本。

根据Terraform's documentation,提供者需要命名为terraform-provider-<NAME>_vX.Y.Zdocumentation for the RKE provider表示该文件应名为terraform-provider-rke(无版本号)。

comment in the Terraform source code for plugin discovery中,它表示支持此无版本格式以实现反向兼容性。但是,Terraform会将版本解释为v0.0.0

在失败的terraform plan之后运行terraform init时,它给了我更多信息:

Error: provider.rke: no suitable version installed
  version requirements: "0.14.1"
  versions installed: "0.0.0"

该版本可能是来自另一个依赖RKE提供程序的提供程序的要求。

我回过头来,从Github存储库中手动下载了确切的版本,并将其复制到名为terraform-provider-rke_v0.14.1的plugins目录中。奏效了!

所以你去了。如有疑问,请查看源代码。现在向Rancher提交问题报告,告诉他们更新文档。 :-)

答案 1 :(得分:1)

对于使用企业防火墙的 Windows 用户,不允许直接下载提供程序的 zip 文件。

  1. 只需访问相应的 URL 即可下载提供商 ZIP 文件。

  • 现在,在根目录 - main.tf 文件中,其中包含提供者部分。
  1. 创建类似 registry.terraform.io\hashicorp\aws\3.37.0\windows_amd64 的文件夹结构,并将从 zip 上方提取的 exe 文件放在此位置。
  2. 转到命令行并运行:

terraform init -plugin-dir .


目录结构:

  • main.tf
  • registry.terraform.io\hashicorp\aws\3.37.0\windows_amd64\terraform_provider_aws_v3.37.0_x5.exe

aws_v3.37.0_x5.exe Directory Structure Snip