I have created the VMSS in Azure
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 ""
and created the Self Hosted Agent Pool in Azure DevOps
However, it is throwing the below error
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.
Below is the Pipeline definition
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'
Update: As suggested in the answer, I have recreated the VMSS with the below custom extension
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" }'
CodePudding user response:
You could test the two workaround below.
1.You could add a bash command $ sudo apt-get install unzip
before the failed task or at the beginning of your pipeline.
2.You could add an Azure VMSS extension to run the command sudo apt-get install unzip
once the VMSS instance is created, and run the pipeline again. You could follow the steps below.
1)Create a .sh file in your public github repo with the command of sudo apt-get install unzip
2)Go to your VMSS resource and follow the three steps in the pic below
//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 \" }'