Using Terraform’s templating feature
Terraform is a very good IaC tool that allows us to build complex infrastructure with code. One of Terraform’s features is the ability to generate text or files based on templates. To illustrate this feature, let’s take a look at a use case I came upon in one of our companies. Of course, there are plenty of use cases for templating with Terraform.
The scenario I’d like to illustrate is the possibility of generating an Ansible inventory file containing the list of host VMs to be configured (using Ansible playbooks) from Terraform configuration, which will have previously provisioned these VMs.
As we studied in Chapter 8, Provisioning Azure Infrastructure with Terraform, concerning the construction of virtual machines, on all cloud providers, the common objective of Terraform is to build a VM without configuring it, which includes the installation of its middleware and its administration.
Ansible (https://www...