google.cloud.gcp_alloydb_cluster module – Creates a GCP Alloydb.Cluster resource
Note
This module is part of the google.cloud collection (version 1.10.2).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install google.cloud.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: google.cloud.gcp_alloydb_cluster.
Synopsis
A managed alloydb cluster.
Requirements
The below requirements are needed on the host that executes this module.
python >= 3.8
requests >= 2.18.4
google-auth >= 2.25.1
Parameters
Parameter |
Comments |
|---|---|
The access token used to authenticate. |
|
Annotations to allow client tools to store small amount of arbitrary data. This is distinct from labels. https://google.aip.dev/128 An object containing a list of “key”: value pairs. Example: { “name”: “wrench”, “mass”: “1.3kg”, “count”: “3” }. |
|
The type of credential used. Choices:
|
|
The automated backup policy for this cluster. AutomatedBackupPolicy is disabled by default. |
|
The length of the time window during which a backup can be taken. If a backup does not succeed within this time window, it will be canceled and considered failed. The backup window must be at least 5 minutes long. There is no upper bound on the window. If not set, it will default to 1 hour. A duration in seconds with up to nine fractional digits, terminated by ‘s’. Example: “3.5s”. |
|
Whether automated backups are enabled. Choices:
|
|
EncryptionConfig describes the encryption config of a cluster or a backup that is encrypted with a CMEK (customer-managed encryption key). |
|
The fully-qualified resource name of the KMS key. Each Cloud KMS key is regionalized and has the following format: projects/[PROJECT]/locations/[REGION]/keyRings/[RING]/cryptoKeys/[KEY_NAME]. |
|
Labels to apply to backups created using this configuration. |
|
The location where the backup will be stored. Currently, the only supported option is to store the backup in the same region as the cluster. |
|
Quantity-based Backup retention policy to retain recent backups. Conflicts with ‘time_based_retention’, both can’t be set together. |
|
The number of backups to retain. |
|
Time-based Backup retention policy. Conflicts with ‘quantity_based_retention’, both can’t be set together. |
|
The retention period. A duration in seconds with up to nine fractional digits, terminated by ‘s’. Example: “3.5s”. |
|
Weekly schedule for the Backup. |
|
The days of the week to perform a backup. At least one day of the week must be provided. |
|
The times during the day to start a backup. At least one start time must be provided. The start times are assumed to be in UTC and to be an exact hour (e.g., 04:00:00). |
|
Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value “24:00:00” for scenarios like business closing time. |
|
Minutes of hour of day. Currently, only the value 0 is supported. |
|
Fractions of seconds in nanoseconds. Currently, only the value 0 is supported. |
|
Seconds of minutes of the time. Currently, only the value 0 is supported. |
|
The ID of the alloydb cluster. |
|
The type of cluster. If not set, defaults to PRIMARY. Choices:
|
|
The continuous backup config for this cluster. If no policy is provided then the default policy will be used. The default policy takes one backup a day and retains backups for 14 days. |
|
Whether continuous backup recovery is enabled. If not set, defaults to true. Choices:
|
|
EncryptionConfig describes the encryption config of a cluster or a backup that is encrypted with a CMEK (customer-managed encryption key). |
|
The fully-qualified resource name of the KMS key. Each Cloud KMS key is regionalized and has the following format: projects/[PROJECT]/locations/[REGION]/keyRings/[RING]/cryptoKeys/[KEY_NAME]. |
|
The numbers of days that are eligible to restore from using PITR. To support the entire recovery window, backups and logs are retained for one day more than the recovery window. If not set, defaults to 14 days. |
|
The database engine major version. This is an optional field and it’s populated at the Cluster creation time. Note: Changing this field to a higer version results in upgrading the AlloyDB cluster which is an irreversible change. |
|
User-settable and human-readable display name for the Cluster. |
|
EncryptionConfig describes the encryption config of a cluster or a backup that is encrypted with a CMEK (customer-managed encryption key). |
|
The fully-qualified resource name of the KMS key. Each Cloud KMS key is regionalized and has the following format: projects/[PROJECT]/locations/[REGION]/keyRings/[RING]/cryptoKeys/[KEY_NAME]. |
|
Specifies which Ansible environment you’re running this module within. This should not be set unless you know what you’re doing. This only alters the User Agent string for any API requests. |
|
For Resource freshness validation (https://google.aip.dev/154). |
|
Initial user to setup during cluster creation. |
|
The initial password for the user. |
|
The database username. |
|
User-defined labels for the alloydb cluster. |
|
The location where the alloydb cluster should reside. |
|
MaintenanceUpdatePolicy defines the policy for system updates. |
|
Preferred windows to perform maintenance. Currently limited to 1. |
|
Preferred day of the week for maintenance, e.g. MONDAY, TUESDAY, etc. Choices:
|
|
Preferred time to start the maintenance operation on the specified day. Maintenance will start within 1 hour of this time. |
|
Hours of day in 24 hour format. Should be from 0 to 23. |
|
Minutes of hour of day. Currently, only the value 0 is supported. |
|
Fractions of seconds in nanoseconds. Currently, only the value 0 is supported. |
|
Seconds of minutes of the time. Currently, only the value 0 is supported. |
|
Metadata related to network configuration. |
|
The name of the allocated IP range for the private IP AlloyDB cluster. For example: “google-managed-services-default”. If set, the instance IPs for this cluster will be created in the allocated range. |
|
The resource link for the VPC network in which cluster resources are created and from which they are accessible via Private IP. The network must belong to the same project as the cluster. It is specified in the form: “projects/{projectNumber}/global/networks/{network_id}”. |
|
The Google Cloud Platform project to use. |
|
Configuration for Private Service Connect (PSC) for the cluster. |
|
Create an instance that allows connections from Private Service Connect endpoints to the instance. Choices:
|
|
The project number that needs to be allowlisted on the network attachment to enable outbound connectivity, if the network attachment is configured to ACCEPT_MANUAL connections. In case the network attachment is configured to ACCEPT_AUTOMATIC, this project number does not need to be allowlisted explicitly. |
|
The source when restoring from a backup. Conflicts with ‘restore_continuous_backup_source’, both can’t be set together. |
|
The name of the backup that this cluster is restored from. |
|
The source when restoring via point in time recovery (PITR). Conflicts with ‘restore_backup_source’, both can’t be set together. |
|
The name of the source cluster that this cluster is restored from. |
|
The point in time that this cluster is restored to, in RFC 3339 format. |
|
Array of scopes to be used. |
|
Configuration of the secondary cluster for Cross Region Replication. This should be set if and only if the cluster is of type SECONDARY. |
|
Name of the primary cluster must be in the format ‘projects/{project}/locations/{location}/clusters/{cluster_id}’. |
|
The contents of a Service Account JSON file, either in a dictionary or as a JSON string that represents it. |
|
An optional service account email address if machineaccount is selected and the user does not wish to use the default email. |
|
The path of a Service Account JSON file if serviceaccount is selected as type. |
|
Whether the resource should exist in GCP. Choices:
|
|
The subscrition type of cluster. Choices:
|
Notes
Note
API Reference: https://cloud.google.com/alloydb/docs/reference/rest/v1/projects.locations.clusters/create
AlloyDB Guide: https://cloud.google.com/alloydb/docs/
For authentication, you can set auth_kind using the
GCP_AUTH_KINDenv variable.For authentication, you can set service_account_file using the
GCP_SERVICE_ACCOUNT_FILEenv variable.For authentication, you can set service_account_contents using the
GCP_SERVICE_ACCOUNT_CONTENTSenv variable.For authentication, you can set service_account_email using the
GCP_SERVICE_ACCOUNT_EMAILenv variable.For authentication, you can set access_token using the
GCP_ACCESS_TOKENenv variable.For authentication, you can set scopes using the
GCP_SCOPESenv variable.Environment variables values will only be used if the playbook values are not set.
The
service_account_email,service_account_file,service_account_fileandaccess_tokenoptions are mutually exclusive.
Examples
- name: Create basic alloydb cluster
google.cloud.gcp_alloydb_cluster:
cluster_id: "{{ resource_name }}"
state: present
location: us-central1
network_config:
network: "projects/{{ gcp_project_number }}/global/networks/{{ resource_name }}"
initial_user:
user: pgroot
password: Test123Test
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
################################################################################
- name: Create primary alloydb cluster
google.cloud.gcp_alloydb_cluster:
cluster_id: "{{ resource_name }}-primary"
state: present
location: us-central1
cluster_type: PRIMARY
network_config:
network: "projects/{{ gcp_project }}/global/networks/default"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
register: _primary
- name: Create secondary cluster attached to primary
google.cloud.gcp_alloydb_cluster:
cluster_id: "{{ resource_name }}-secondary"
state: present
location: us-central1
cluster_type: SECONDARY
network_config:
network: "projects/{{ gcp_project }}/global/networks/default"
secondary_config:
primary_cluster_name: "{{ _primary.name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Cluster created from backup. Returned: success |
|
The name of the backup resource. Returned: when set |
|
Whether the resource was changed. Returned: always |
|
ContinuousBackupInfo describes the continuous backup properties of a cluster. Returned: success |
|
The earliest restorable time that can be restored to. Output only field. Returned: success |
|
When ContinuousBackup was most recently enabled. Set to null if ContinuousBackup is not enabled. Returned: success |
|
Output only. The encryption information for the WALs and backups required for ContinuousBackup. Returned: success |
|
Output only. Type of encryption. Returned: success |
|
Output only. Cloud KMS key versions that are being used to protect the database or the backup. Returned: success |
|
Days of the week on which a continuous backup is taken. Output only field. Ignored if passed into the request. Returned: success |
|
EncryptionInfo describes the encryption information of a cluster or a backup. Returned: success |
|
Output only. Type of encryption. Returned: success |
|
Output only. Cloud KMS key versions that are being used to protect the database or the backup. Returned: success |
|
Cluster created via DMS migration. Returned: success |
|
The host and port of the on-premises instance in host:port format. Returned: when set |
|
Place holder for the external source identifier(e.g DMS job name) that created the cluster. Returned: when set |
|
Type of migration source. Returned: when set |
|
The name of the cluster resource. Returned: success |
|
Output only. Reconciling (https://google.aip.dev/128#reconciliation). Set to true if the current state of Cluster does not match the user’s intended state, and the service is actively updating the resource to reconcile them. This can happen due to user-triggered updates or system actions like failover or maintenance. Returned: success |
|
Output only. The current serving state of the cluster. Returned: success |
|
Contains information and all metadata related to TRIAL clusters. Returned: success |
|
End time of the trial cluster. Returned: when set |
|
Grace end time of the trial cluster. Returned: when set |
|
Start time of the trial cluster. Returned: when set |
|
Upgrade time of the trial cluster to standard cluster. Returned: when set |
|
The system-generated UID of the resource. Returned: success |