为什么 Terraform 看不到我手动安装的提供程序? [英] Why doesn't Terraform see my manually installed provider?
问题描述
我正在尝试将 RKE 提供程序 安装为Rancher AWS 快速入门的一部分.Terraform 文档 说插件应该安装在 ~/.terraform.d/plugins
.RKE 文档说插件应该安装在 ~/terraform.d/plugins/<your_platform>
.
I'm trying to install the RKE provider as part of the Rancher AWS quickstart. The Terraform documentation says that plugins should be installed at ~/.terraform.d/plugins
. The RKE documentation says that the plugin should be installed at ~/terraform.d/plugins/<your_platform>
.
为了协调相互冲突的信息,我尝试将二进制文件复制到以下所有位置,但 Terraform 从未见过它们中的任何一个:
Trying to reconcile the conflicting information, I tried copying the binary to all of the following locations, but Terraform never saw any of them:
~/.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
时,都会出现以下错误:
In each case, when I ran terraform init
, I got the following error:
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 看不到任何自动下载的插件,我必须手动安装所有内容.
As a last resort, I could use terraform init -plugin-dir=<something>
. But then Terraform doesn't see any of the automatically downloaded plugins, and I have to manually install everything.
是否缺少一些路径变量,或者我未能遵循的其他命名约定?
Is there some path variable that's missing, or some other naming convention that I am failing to follow?
推荐答案
原来错误信息并没有说明全部.Terraform 正在寻找提供者,但它认为它的版本不够新.
It turns out that the error message didn't tell the whole story. Terraform was finding the provider, but it didn't think it was a new enough version.
根据Terraform 的文档,提供者需要命名为 terraform-provider-<NAME>_vX.YZ
.RKE 提供者的文档 说该文件应该被称为 terraform-provider-rke
(没有版本号).
According to Terraform's documentation, the provider needs to be named as terraform-provider-<NAME>_vX.Y.Z
. The documentation for the RKE provider said that the file should be called terraform-provider-rke
(no version number).
在插件的 Terraform 源代码中的 评论中发现,它表示支持这种无版本格式以实现反向兼容性.但是,Terraform 将版本解释为 v0.0.0
.
In a comment in the Terraform source code for plugin discovery, it says that this versionless format is supported for reverse compatibility. However, Terraform interprets the version to be v0.0.0
.
当我在失败的 terraform init
之后运行 terraform plan
时,它给了我一个信息更丰富的错误消息:
When I ran terraform plan
after the failed terraform init
, it gave me a more informative error message:
Error: provider.rke: no suitable version installed
version requirements: "0.14.1"
versions installed: "0.0.0"
该版本可能是来自另一个依赖于 RKE 提供者的提供者的要求.
That version is presumably a requirement from another provider that depends on the RKE provider.
我返回并从 Github 存储库手动下载了该确切版本,并将其复制到名为 terraform-provider-rke_v0.14.1
的插件目录中.成功了!
I went back and manually downloaded that exact version from the Github repo and copied it into the plugins directory with the name terraform-provider-rke_v0.14.1
. It worked!
所以你去.如有疑问,请查看源代码.现在向 Rancher 提交问题报告,告诉他们更新他们的文档.:-)
So there you go. When in doubt, look at the source code. Now to submit an issue report to Rancher, telling them to update their documentation. :-)
这篇关于为什么 Terraform 看不到我手动安装的提供程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!