Skip to content

Wiring tofu outputs to another job / script

i'm in the process of using this template for a project which has multiple environments, and have achieved a dev -> prod pipeline by using seperate stages to ensure that dev applies first, before proceeding to upper envs.

I am trying to figure out how i can wire in tofu output information such that i can then run ansible to configure some virtual machines provisioned via the tofu apply . Since the information i require is unknown until apply (the IP addresses of the VM'), i have a few options:

  • Understand how to empower passing artifacts from the apply job (create a file with the inventory.ini within tofu and use that within a seperate job
  • Try to use tofu output to pass information
  • Use an ansible inventory plugin (i'm leaning more to this purely because it means i don't have to alter a base job which is extended within the templates of validate-plan-apply

Wondered if there was any immediate thoughts on using output / artifacts from an apply to follow up jobs (using seperate jobs means i can maintain slim images which either just run tofu or ansible commands rather than requiring an image with everything inside)