gpt4 book ai didi

Azure DevOps 自托管代理 VMSS : Unable to locate executable file: 'unzip'

转载 作者:行者123 更新时间:2023-12-03 05:18:06 29 4
gpt4 key购买 nike

我已在 Azure 中创建了 VMSS

az group create --location eastus --name vmssagents

az vmss create --name vmssagentspool --resource-group vmssagents --image UbuntuLTS --vm-sku Standard_B1s --storage-sku StandardSSD_LRS --authentication-type SSH --generate-ssh-keys --instance-count 2 --disable-overprovision --upgrade-policy-mode manual --single-placement-group false --platform-fault-domain-count 1 --load-balancer ""

并在 Azure DevOps 中创建了自托管代理池

enter image description here

但是,它抛出以下错误

Error: Unable to locate executable file: 'unzip'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

下面是管道定义

trigger: none

pool: 'Self Hosted'

variables:
bkstrgrg: azDevTFTestRG
bkstrg: cirazadopstest2
bkcontainer: tfstate
bkstrgkey: devpipeline.terraform.tfstate

stages:
- stage: tfvalidate
jobs:
- job: validate
continueOnError: false
steps:
- task: TerraformInstaller@0
displayName: tfinstall
inputs:
terraformVersion: 'latest'

- task: TerraformTaskv3@3
displayName: init
inputs:
provider: 'azurerm'
command: 'init'
backendServiceArm: 'Azure-Landing-Zone-Deployment'
backendAzureRmResourceGroupName: '$(bkstrgrg)'
backendAzureRmStorageAccountName: '$(bkstrg)'
backendAzureRmContainerName: '$(bkcontainer)'
backendAzureRmKey: '$(bkstrgkey)'

- task: TerraformTaskV3@3
displayName: validate
inputs:
provider: 'azurerm'
command: 'validate'

- stage: tfdeploy
condition: succeeded ('tfvalidate')
dependsOn: tfvalidate
jobs:
- job: apply
steps:
- task: TerraformInstaller@0
displayName: tfinstall
inputs:
terraformVersion: 'latest'

- task: TerraformTaskv3@3
displayName: init
inputs:
provider: 'azurerm'
command: 'init'
backendServiceArm: 'Azure-Landing-Zone-Deployment'
backendAzureRmResourceGroupName: '$(bkstrgrg)'
backendAzureRmStorageAccountName: '$(bkstrg)'
backendAzureRmContainerName: '$(bkcontainer)'
backendAzureRmKey: '$(bkstrgkey)'

- task: TerraformTaskV3@3
displayName: validate
inputs:
provider: 'azurerm'
command: 'validate'

- task: TerraformTaskv3@3
displayName: plan
inputs:
provider: 'azurerm'
command: 'plan'
environmentServiceNameAzureRM: 'Azure-Landing-Zone-Deployment'

- task: TerraformTaskv3@3
displayName: apply
inputs:
provider: 'azurerm'
command: 'apply'
environmentServiceNameAzureRM: 'Azure-Landing-Zone-Deployment'

更新:按照答案中的建议,我使用以下自定义扩展重新创建了 VMSS

az vmss extension set --vmss-name vmssagentspool --resource-group vmssagents  --name CustomScript --version 2.0 --publisher Microsoft.Azure.Extensions --settings '{"fileUris":["https://raw.githubusercontent.com/kavija/azure-devops-custom-installers/main/zip_install.sh"],"commandToExecute":"bash ./zip_install.sh" }'

最佳答案

您可以测试下面的两个解决方法。

1.您可以在失败的任务之前或管道的开头添加 bash 命令 $ sudo apt-get install unzip

2.您可以添加 Azure VMSS 扩展,以便在创建 VMSS 实例后运行命令 sudo apt-get install unzip,然后再次运行管道。您可以按照以下步骤操作。1)使用sudo apt-get install unzip命令在公共(public)github存储库中创建一个.sh文件2)转到您的 VMSS 资源并按照下图中的三个步骤操作

//script in step 2
az vmss extension set --vmss-name ubuntu --resource-group {Your Res Group} --name CustomScript --version 2.0 --publisher Microsoft.Azure.Extensions --settings '{ \"fileUris\":[\"https://{YourPublicRepo}/AddUnzip.sh\"], \"commandToExecute\": \"bash ./AddUnzip.sh /myArgs \" }'

enter image description here

关于Azure DevOps 自托管代理 VMSS : Unable to locate executable file: 'unzip' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73901666/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com