I have set up Terraform Enterprise on an Ubuntu Azure VM and have integrated it with Service Now and Azure Dev Ops. Whenever there is a new ticket created in Service Now using specific catalog item, terraform workspace gets provisioned and starts a run using passed variable values. The terraform code runs at Ubuntu18.04 Azure VM. I have a requirement where I need to run Az commands using "Local-Exec" provisioner to install a custom script extension on a VM where it is already installed and need to run a powershell on that VM. I am using below code.
provisioner "local-exec" {
command = <<EOH
az login --identity
az account set --subscription=${local.subscription_id}
az vm extension set --resource-group ${data.azurerm_resource_group.rg.name} --vm-name ${var.azure_vm_name} --name CustomScriptExtension --publisher Microsoft.Compute --extension-instance-name CustomScriptExtension --settings .//settings.json --version 1.9 --force-update
EOH
interpreter = ["pwsh","-command"]
}
I have installed PowerShell Core on my Ubuntu machine and it resides here - /usr/bin/pwsh
on my machine.
Whenever I am triggering the run, it is failing with below error message.
Error: Error running command ' az login --identity
az account set --subscription=<My Subscription ID>
az vm extension set --resource-group <my resource group> --vm-name <VM Name> --name CustomScriptExtension --publisher Microsoft.Compute --extension-instance-name CustomScriptExtension --settings .//settings.json --version 1.9 --force-update
exec: "pwsh": executable file not found in $PATH. Output:
Does anybody faced the same issue or can anybody help me on this?