为什么Terraform看不到我手动安装的供应商?

问题描述 投票:0回答:1

我正在尝试安装 RKE提供者 属于 Rancher AWS快速入门. 该 梯形文件 说,插件应该安装在 ~/.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看不到任何自动下载的插件,我不得不手动安装所有的东西。

是不是缺少了一些路径变量,或者我没有遵循其他的命名规则?

macos terraform rancher rke
1个回答
3
投票

事实证明,错误信息并没有告诉整个故事。Terraform正在寻找提供者,但它认为它不是一个足够新的版本。

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

在一个 在Terraform源码中添加注释,以便发现插件它说这种无版本的格式是支持反向兼容的。然而,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 repo 中手动下载了那个确切的版本,并将其复制到插件目录中,命名为 "RKE"。terraform-provider-rke_v0.14.1. 成功了!

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

© www.soinside.com 2019 - 2024. All rights reserved.