Check Ansible 2.8/latest doc.
There is a module for creating GCP CloudSQL instance & database:
TASK
- name: Create GCP CloudSQL instance
gcp_sql_instance:
name: '{{ sql_instance.name }}'
backend_type: '{{ sql_instance.backend_type }}'
database_version: '{{ sql_instance.database_version }}'
settings:
tier: '{{ sql_instance.tier }}'
region: '{{ sql_instance.region }}'
project: '{{ project_id }}'
auth_kind: '{{ authentification_type }}'
service_account_file: '{{ credentials_file }}'
state: present
VARIABLES
### authentification
# authentification_type: application / machineaccount / serviceaccount
# service_account_file: "/path/to/auth.json"
project_id: []
authentification_type: serviceaccount
credentials_file: []
### Cloud_SQL instance specifications
# backend_type: FIRST_GEN / SECOND_GEN / EXTERNAL
# database_version: MYSQL_5_5 / MYSQL_5_6 / MYSQL_587 / POSTGRESQL_9_6
# tier: db-g1-smal / db-pg-g1-small / custom-2-2048
sql_instance:
name: []
backend_type: []
database_version: []
region: []
tier: []