Unable to run Terraform using Self Hosted Linux agent

Hi all,

I am having issues in running terraform steps using Azure Devops through self hosted linux agent.

Below is my pipeline code:-

trigger:
none
pr:

  • ‘*’
    pool:
    name: Self-Hosted-Agent(pool name)
    demands:

    • agent.name -equals vmmgmtpuks0019(agent name)
      stages:
  • stage: terraform_installation
    jobs:

    • job: installation
      steps:
      • task: TerraformInstaller@1
        displayName: ‘Terraform installation’
        inputs:
        terraformVersion: ‘latest’
  • stage: terraform_init
    jobs:

    • job: init
      steps:
      • checkout: self

      • task: TerraformTaskV4@4
        displayName: ‘Terraform init’
        inputs:
        provider: ‘azurerm’
        command: ‘init’
        workingDirectory: ‘
        environmentServiceNameAzureRM: '

        backendServiceArm: ‘
        backendAzureRmResourceGroupName: '

        backendAzureRmStorageAccountName: ‘
        backendAzureRmContainerName: '

        backendAzureRmKey: ‘**’

Terraform installation step is working and below is the logs:-

Starting: Terraform installation

Task : Terraform tool installer
Description : Find in cache or download a specific version of Terraform and prepend it to the PATH
Version : 1.216.24
Author : Microsoft Corporation
Help : Learn more about this task

Getting latest Terraform version.
Downloading: https://releases.hashicorp.com/terraform/1.7.5/terraform_1.7.5_linux_amd64.zip
Extracting archive
/usr/bin/unzip /package/_work/_temp/terraform-1.7.5-90331641-692a-439d-9d2d-eadd8ae50420.zip
Archive: /package/_work/_temp/terraform-1.7.5-90331641-692a-439d-9d2d-eadd8ae50420.zip
inflating: terraform
Caching tool: terraform 1.7.5 x64
Prepending PATH environment variable with directory: /package/_work/_tool/terraform/1.7.5/x64
Verifying Terraform installation…
/package/_work/_tool/terraform/1.7.5/x64/terraform version
Terraform v1.7.5
on linux_amd64
Finishing: Terraform installation

However, the terraform init step is failing with below logs:-
Starting: Terraform init

Task : Terraform
Description : Execute terraform commands to manage resources on AzureRM, Amazon Web Services(AWS) and Google Cloud Platform(GCP)
Version : 4.227.24
Author : Microsoft Corporation
Help : Learn more about this task

##[error]Error: Failed to find terraform tool in paths
Finishing: Terraform init

I have even updated the environment variable within the linux machine manually to point to “/package/_work/_tool/terraform/1.7.5/x64”

Can someone kindly suggest the remedy for this

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.