Creating a Cloud SQL instance (without Ansible module)
Google Cloud has several tools and features for which Ansible modules are not available at the time of writing. In such cases we can use a shell module and Google Cloud SDK's gcloud command line tool. One such component of Google Cloud is Cloud SQL which provides managed MySQL and PostgreSQL instances.
How to do it…
Let us build an instance of MySQL using Ansible and gcloud:
- We will start by configuring the
gcloud
tool. In order to keep ourmain.yml
clean, we will move the gcloud configuration tasks into a different YAML file,configure_gcloud.yml
, and import it inmain.yml
. In this YAML file, we have Ansible tasks to take care of installing the Google SDK repository on various Linux distributions, including Red Hat Enterprise Linux, CentOS, Fedora, Debian, and Ubuntu. These need super user privileges. We have included the repository files in the code base. Ourconfigure_gcloud.yml
would look like this:
--- - name: enable Google SDK repo...