Dynamic inventory
Managing the inventory file manually can be a problem. In an environment where instances are booted up and destroyed very frequently, a text-based inventory file can easily go out of sync from the actual infrastructure. In such cases, we can use dynamic inventory, which will help us generate the list of compute instances and other resources in real time. Ansible's GitHub repository has a dynamic inventory script for OpenStack.
How to do it…
Let's download the dynamic inventory script and set the executable bit as follows:
$ curl https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/openstack.py > openstack.py $ chmod +x openstack.py
After we set the executable bit, we need to set the environment variables so that the inventory script can authenticate with the OpenStack keystone. The easiest way to set up the environment variables is to execute the script that we downloaded from the Horizon dashboard in the first recipe, Preparing Ansible to work with...