The purpose of this recipe is not to discuss the installation and use of Ansible but just the automatic creation of its inventory file.
To learn more about Ansible, I invite you to read Chapter 3, Using Ansible for Configuring IaaS Infrastructure, from my book entitled Learning DevOps, also available from Packt at https://www.packtpub.com/eu/cloud-networking/learning-devops.
The starting point of our recipe is to use Terraform to create VMs in Azure whose private IP addresses are not known before they are created. In this Terraform configuration of VMs, we use the configuration we have already studied in the Provisioning and configuring an Azure VM with Terraform recipe of Chapter 6, Provisioning Azure Infrastructure with Terraform. So, to keep it simple, we use the Terraform modules published in the public registry with the following Terraform configuration:
- Instantiate a vmhosts variable that specifies the hostname of the VM we want...