terraform - Terraform:无法安装提供程序,与依赖锁定文件中的校验和不匹配
问题描述
我使用 CI 系统编译 terraform 提供程序并将它们捆绑到图像中,但是每次运行 terraform init 时,都会出现以下错误/失败。
│ Error: Failed to install provider
│
│ Error while installing rancher/rancher2 v1.13.0: the current package for
│ registry.terraform.io/rancher/rancher2 1.13.0 doesn't match any of the
│ checksums previously recorded in the dependency lock file
对我的提供程序文件中列出的所有提供程序重复此消息,如下所示:
terraform {
required_version = ">= 0.13"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.55.0"
}
github = {
source = "integrations/github"
version = "4.8.0"
}
}
...snip...
}
terraform hcl 锁定文件存储在 repo 中,只有当 repo 中存在锁定文件时,才会出现这些错误并且 terraform init 失败。可能是什么原因?
解决方案
问题是我的本地工作站是使用 darwin 平台的 Mac,因此为 darwin 下载了所有提供程序,并将哈希值存储在该平台的锁定文件中。当在 Linux 上运行的 CI 系统运行时,它会尝试检索锁定文件中列出的提供程序,但校验和不匹配,因为它们使用不同的平台。
解决方案是在本地使用以下命令生成一个新的 terraform 依赖锁文件,所有平台都为 terraform,运行在不同平台上的其他系统将能够服从依赖锁文件。
terraform providers lock -platform=windows_amd64 -platform=darwin_amd64 -platform=linux_amd64
推荐阅读
- r - 在 KFAS 上自动使用 SSMcustom 以获得时间序列每日效果
- python - 当 SpaCy 仅支持标记化(pl - 波兰语)时,如何更改 Rasa NLU 中的语言?
- android - First visible item in recycler view chagnes rest of the list
- angular - 基于用户选择顺序保存的多个选择 ngModel 绑定值
- git - 在保留 3-Way 合并信息的同时解决 IDE 中的合并冲突
- android - RecyclerView 洗牌项目
- html - 遍历 mat-table Angular 中的数据源
- android - 在 android studio 应用程序中使用来自 Sklearm python 的回归模型
- ios - ARKit 透视渲染
- javascript - iOS onClose WebSocket 事件无法正常工作