我使用 CI 系统编译 terraform 提供程序并将它们捆绑到图像中,但每次运行 terraform init 时,都会收到以下错误/失败。
\n\xe2\x94\x82 Error: Failed to install provider\n\xe2\x94\x82 \n\xe2\x94\x82 Error while installing rancher/rancher2 v1.13.0: the current package for\n\xe2\x94\x82 registry.terraform.io/rancher/rancher2 1.13.0 doesn't match any of the\n\xe2\x94\x82 checksums previously recorded in the dependency lock file\nRun Code Online (Sandbox Code Playgroud)\n对于我的提供程序文件中列出的所有提供程序,都会重复此消息,如下所示:
\nterraform {\n required_version = ">= 0.13"\n\n required_providers {\n azurerm = {\n source = "hashicorp/azurerm"\n version = "2.55.0"\n }\n github = {\n source = "integrations/github"\n version = "4.8.0"\n }\n }\n...snip...\n}\nRun Code Online (Sandbox Code Playgroud)\nterraform hcl 锁定文件存储在存储库中,只有当存储库中存在锁定文件时,才会出现这些错误并且 terraform init 失败。可能是什么原因?
\nHig*_*ife 62
问题是我的本地工作站是使用 darwin 平台的 Mac,因此下载了 darwin 的所有提供程序,并将哈希值存储在该平台的锁定文件中。当在 Linux 上运行的 CI 系统运行时,它会尝试检索锁定文件中列出的提供程序,但校验和不匹配,因为它们使用不同的平台。
解决方案是在本地使用以下命令为 terraform 的所有平台生成一个新的 terraform 依赖锁定文件,然后在不同平台上运行的其他系统将能够遵守该依赖锁定文件。
terraform providers lock -platform=windows_amd64 -platform=darwin_amd64 -platform=linux_amd64
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29095 次 |
| 最近记录: |