Ansible - GCP Dynamic inventory bootstrap
Ansible GCP module bootstrap
The official docs on Ansible GCP module are quite a bit confusing, so I’ve decided to publish some steps to quickly bootstrap a working environment.
Main concept is that Ansible can not only use static files as a source of inventory but also execute a script and use it’s output as an in-memory representation of it. This allows us to make dynamic inventories to load up hosts from your cloud provider, for example. And, conveniently, there’s such a script in the Ansible’s
contrib directory named
This assumes you already have:
- Ansible installed
- A working python installation
- Have a service account with Compute Engine API access
- Exported a JSON key in Credentials subsection of your console
Here are quick bootstrap instructions on how to get it working:
Install libcloud and libcrypto:
λ pip install apache-libcloud pycrypto
Create a working dir:...
Continue reading →