Azure DevOps 管道 Terraform Init 失败
Azure DevOps Pipeline Terraform Init fail
我目前卡在 Azure DevOps 管道的初始点。所以我成功安装了Terraform,但是下一步已经失败了。
pool:
name: Azure Pipelines
vmImage: ubuntu-latest
variables:
- name: terraform-working-directory
value: '$(System.DefaultWorkingDirectory)/terraform/'
stages :
- stage: terraform
jobs:
- deployment: deploy_terraform
continueOnError: false
environment: 'dev'
strategy:
runOnce:
deploy:
steps:
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller@0
displayName: 'install'
inputs:
terraformVersion: '0.14.11'
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI@0
displayName: 'init'
inputs:
command: 'init'
workingDirectory: $(terraform-working-directory)
backendType: 'self-configured'
地形文件:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.63.0"
}
}
backend "azurerm" {
resource_group_name = "xxx"
storage_account_name = "xxx"
container_name = "xxx"
key = "terraform.tfstate"
}
}
它目前真的很基础,才刚刚开始。我收到的错误消息如下:
/opt/hostedtoolcache/terraform/0.14.11/x64/terraform init -backend-config=storage_account_name=xxx -backend-config=container_name=xxx -backend-config=key=xxx -backend-config=resource_group_name=xxx -backend-config=arm_subscription_id=xxx -backend-config=arm_tenant_id=*** -backend-config=arm_client_id=*** -backend-config=arm_client_secret=***
##[error]Error: There was an error when attempting to execute the process '/opt/hostedtoolcache/terraform/0.14.11/x64/terraform'. This may indicate the process failed to start. Error: spawn /opt/hostedtoolcache/terraform/1.0.0/x64/terraform ENOENT
Finishing: terraform init
我已经在本地启动了 terraform init 和 apply,效果很好
请确保您有正确的工作目录。该消息具有误导性。这个问题实际上是因为 terraform 找不到你的 tf 文件。
请添加此步骤以检查您的目录是否正确
- bash: ls $(terraform-working-directory)
您使用部署作业,这里的存储库不是开箱即用的。请在作业最开头加上- checkout: self
。
我目前卡在 Azure DevOps 管道的初始点。所以我成功安装了Terraform,但是下一步已经失败了。
pool:
name: Azure Pipelines
vmImage: ubuntu-latest
variables:
- name: terraform-working-directory
value: '$(System.DefaultWorkingDirectory)/terraform/'
stages :
- stage: terraform
jobs:
- deployment: deploy_terraform
continueOnError: false
environment: 'dev'
strategy:
runOnce:
deploy:
steps:
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller@0
displayName: 'install'
inputs:
terraformVersion: '0.14.11'
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI@0
displayName: 'init'
inputs:
command: 'init'
workingDirectory: $(terraform-working-directory)
backendType: 'self-configured'
地形文件:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.63.0"
}
}
backend "azurerm" {
resource_group_name = "xxx"
storage_account_name = "xxx"
container_name = "xxx"
key = "terraform.tfstate"
}
}
它目前真的很基础,才刚刚开始。我收到的错误消息如下:
/opt/hostedtoolcache/terraform/0.14.11/x64/terraform init -backend-config=storage_account_name=xxx -backend-config=container_name=xxx -backend-config=key=xxx -backend-config=resource_group_name=xxx -backend-config=arm_subscription_id=xxx -backend-config=arm_tenant_id=*** -backend-config=arm_client_id=*** -backend-config=arm_client_secret=***
##[error]Error: There was an error when attempting to execute the process '/opt/hostedtoolcache/terraform/0.14.11/x64/terraform'. This may indicate the process failed to start. Error: spawn /opt/hostedtoolcache/terraform/1.0.0/x64/terraform ENOENT
Finishing: terraform init
我已经在本地启动了 terraform init 和 apply,效果很好
请确保您有正确的工作目录。该消息具有误导性。这个问题实际上是因为 terraform 找不到你的 tf 文件。
请添加此步骤以检查您的目录是否正确
- bash: ls $(terraform-working-directory)
您使用部署作业,这里的存储库不是开箱即用的。请在作业最开头加上- checkout: self
。