5

我正在尝试将RKE 提供程序安装为Rancher AWS quickstart的一部分。Terraform 文档说插件应该安装在~/.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 看不到任何自动下载的插件,我必须手动安装所有内容。

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

4

2 回答 2

7

事实证明,错误消息并没有说明全部情况。Terraform 正在寻找提供者,但它认为它的版本不够新。

根据Terraform 的文档,提供者需要命名为terraform-provider-<NAME>_vX.Y.Z. RKE 提供者的文档说应该调用该文件terraform-provider-rke(没有版本号)。

用于插件发现的 Terraform 源代码中的评论中,它说支持这种无版本格式以实现反向兼容性。但是,Terraform 将版本解释为v0.0.0.

当我terraform plan在 failed 之后运行时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. 有效!

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

于 2020-05-05T00:35:28.447 回答
2

对于企业防火墙上的 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 。


目录结构:

  • 主文件
  • registry.terraform.io\hashicorp\aws\3.37.0\windows_amd64\terraform_provider_aws_v3.37.0_x5.exe

aws_v3.37.0_x5.exe 目录结构片段

于 2021-04-20T11:37:27.007 回答