ansible-collections / cloud.terraform

The collection automates the management and provisioning of infrastructure as code (IaC) using the Terraform CLI tool within Ansible playbooks and Execution Environment runtimes.
GNU General Public License v3.0
100 stars 36 forks source link

Support falling back to `tofu` binary if `terraform` is not found but `tofu` is (And maybe allow the fallback to be an environment variable) #159

Open x86-39 opened 4 months ago

x86-39 commented 4 months ago
SUMMARY

As OpenTofu and Terraform both should work for this collection, I think it would be a good idea to fall back to tofu if it is found and terraform is not

ISSUE TYPE
COMPONENT NAME

The inventory provider, all modules and the lookup provider

ADDITIONAL INFORMATION

OpenTofu is getting more popular, and it's compatible with Terraform. People should be able to use OpenTofu instead of Terraform without needing to hardcode the binary path in the inventory file/tasks.

Alternatively, or both, an environment variable could be used to get the Terraform/Tofu binary path. This would not break any deployments, as the hardcoded path in the task/inventory would still take precedent.

My proposed search order is as follows:

If this sounds like something that would be accepted, I can make a PR for it