semaphoreui / semaphore

Modern UI and powerful API for Ansible, Terraform, OpenTofu, PowerShell and other DevOps tools.
https://semaphoreui.com
MIT License
10.64k stars 1.07k forks source link

Semaphore + Terraform/OpenTofu with Azure CLI credentials #2388

Open mlanner opened 1 month ago

mlanner commented 1 month ago

Discussed in https://github.com/semaphoreui/semaphore/discussions/2386

Originally posted by **mlanner** October 1, 2024 I have a Terraform/OpenTofu project for Azure that works just fine if run from the command line. The project uses Azure's CLI and specifically `az login` to consistently build the resources in Azure as defined in the `main.tf` code. I recently added this project to Semaphore and it all looks right (to me) and it successfully initializes the workspace when starting the task. However, as soon as it starts running the `tofu plan` it fails and says to run `az login`. I assume this is because Semaphore can't read the Azure CLI env variables? But, no matter if that assumption is right or wrong, I'd like to understand how I can make Semaphore execute my task. My goal is to use Semaphore to make this easier for other people on my team to stand up infrastructure without needing to know a lot about Terraform, using the command line, or even having CLI access to the server. Any suggestions, ideas or insights into how to go about it would be greatly appreciated. Thanks in advance!
mlanner commented 1 month ago

Follow up ... Having tried a few more things and also having had a colleague review it with me, I'm thinking this might be a bug. I'd be happy to be proven wrong on that, or just be told how to handle it, but for right now I can't make it work using Semaphore, while it is working just fine using tofu plan and/or tofu apply on the command line.