When configuring an infrastructure that is composed of several VMs, along with ephemeral environments that are built on demand, the observation often made is that maintaining a static inventory, as we saw in the Creating an inventory for targeting Ansible hosts section, can quickly become complicated and its maintenance takes a lot of time.
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 and that aims to return the contents of the inventory.
In this section, we will see the different steps to use Ansible to configure VMs in Azure using a dynamic inventory:
- The first step is to configure Ansible to be able to access Azure resources. For this, we will create an Azure Service Principal...