Closed EdanBrooke closed 8 months ago
Hello,
The below works, specifying the Terraform binary as Terragrunt.
---
plugin: cloud.terraform.terraform_provider
binary_path: "/home/linuxbrew/.linuxbrew/bin/terragrunt" # Use Terragrunt wrapper
project_path: "../terraform/environments/lab/azurerm/core"
search_child_modules: True
Of course, for this to work you'd have to create a separate YAML file inside your inventory
directory for each Terragrunt directory that yields Ansible Terraform provider resources. I'm OK with this personally.
However, specifying only terragrunt
fails. I believe that adding support for binary_path
to be either absolute, or relative to any path within $PATH
may be an effective way to resolve this?
Thanks.
Because I'm using Terragrunt, I realised I can actually use a generate
block to build the inventory YAML files on the fly.
I've added the following to my root terragrunt.hcl
:
generate "inventory" {
path = "${get_repo_root()}/ansible/inventory/terraform-${local.state_name).yml"
if_exists = "overwrite"
contents = <<EOF
---
plugin: cloud.terraform.terraform_provider
binary_path: "${run_cmd("--terragrunt-quiet", "/usr/bin/which", "terragrunt")}" # Use Terragrunt wrapper
project_path: "${get_terragrunt_dir()}"
EOF
}
Consider this resolved, thanks.
Hi,
I would like to use this plugin to dynamically build our Ansible inventories. I got this working with Terraform on its own, but we're now looking to use Terragrunt with HTTP (GitLab) remote state. This doesn't seem to be possible at the moment as specifying the path to the a Terragrunt directory doesn't yield a backend configuration or a Terraform state file:
Is there a particular place I should post in the community to discuss this?