我正在尝试将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看不到任何自动下载的插件,因此我必须手动安装所有内容。
是否缺少一些路径变量,或者我没有遵循的其他命名约定?
答案 0 :(得分:6)
事实证明该错误消息并没有说明全部。 Terraform正在查找提供程序,但它认为这不是一个足够新的版本。
根据Terraform's documentation,提供者需要命名为terraform-provider-<NAME>_vX.Y.Z
。 documentation 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 文件。
terraform init -plugin-dir .
目录结构: