Managing inventory in a text file can be a problem. A large cluster could overwhelm the maintainer of the inventory. On top of that, often the instances can be scaled at short notice. Keeping this in mind, we can use dynamic inventory to build and run playbooks on instances based on specific parameters. A list of instances is generated in real time, eliminating the need for maintaining an inventory manually.
Using dynamic inventory
How to do it...
- Ansible's Github repository has scripts for various infrastructure providers, including a script for Google Compute Engine (https://github.com/ansible/ansible/blob/devel/contrib/inventory/gce.py). We need to download this script and configure it to use our credentials:
$...