Using a dynamic inventory for an Azure infrastructure
When configuring an infrastructure that is composed of several VMs, along with ephemeral environments that are built on demand, the observation that's often made is that maintaining a static inventory, as we saw in the Creating an Ansible inventory section, can quickly become complicated and its maintenance takes a lot of time to complete.
To overcome this problem, Ansible allows inventories to be obtained dynamically by calling a script (for example, in Python) that is either provided by cloud providers or a script that we can develop ourselves that returns the contents of the inventory.
In this section, we will look at the different ways to use Ansible to configure VMs in Azure using a dynamic inventory. Let's get started:
- The first step is to configure Ansible to be able to access Azure resources. For this, we will create an Azure Service Principal in Azure AD, in exactly the same way as we did for Terraform...