| 1 |
# ---------------------------------------------------------------------------- |
| 2 |
# |
| 3 |
# *** AUTO GENERATED CODE *** Type: MMv1 *** |
| 4 |
# |
| 5 |
# ---------------------------------------------------------------------------- |
| 6 |
# |
| 7 |
# This file is automatically generated by Magic Modules and manual |
| 8 |
# changes will be clobbered when the file is regenerated. |
| 9 |
# |
| 10 |
# ---------------------------------------------------------------------------- |
| 11 |
- name: Main test block |
| 12 |
block: |
| 13 |
- name: Create test network |
| 14 |
google.cloud.gcp_compute_network: |
| 15 |
name: "{{ resource_name }}" |
| 16 |
state: present |
| 17 |
auto_create_subnetworks: true |
| 18 |
project: "{{ gcp_project }}" |
| 19 |
auth_kind: "{{ gcp_cred_kind }}" |
| 20 |
service_account_file: "{{ gcp_cred_file }}" |
| 21 |
register: _network |
| 22 |
|
| 23 |
- name: Test case |
| 24 |
block: |
| 25 |
- name: Create peering range |
| 26 |
google.cloud.gcp_compute_global_address: |
| 27 |
name: "{{ resource_name }}-peering" |
| 28 |
state: present |
| 29 |
address_type: INTERNAL |
| 30 |
prefix_length: 16 |
| 31 |
purpose: VPC_PEERING |
| 32 |
network: "{{ _network }}" |
| 33 |
project: "{{ gcp_project }}" |
| 34 |
auth_kind: "{{ gcp_cred_kind }}" |
| 35 |
service_account_file: "{{ gcp_cred_file }}" |
| 36 |
|
| 37 |
- name: Connect peering range |
| 38 |
ansible.builtin.command: > |
| 39 |
gcloud services vpc-peerings connect |
| 40 |
--quiet |
| 41 |
--service=servicenetworking.googleapis.com |
| 42 |
--ranges="{{ resource_name }}-peering" |
| 43 |
--network="{{ _network.name }}" |
| 44 |
--project="{{ gcp_project }}" |
| 45 |
|
| 46 |
- name: Create primary alloydb cluster |
| 47 |
google.cloud.gcp_alloydb_cluster: |
| 48 |
cluster_id: "{{ resource_name }}-primary" |
| 49 |
state: present |
| 50 |
location: us-central1 |
| 51 |
cluster_type: PRIMARY |
| 52 |
initial_user: |
| 53 |
user: pgroot |
| 54 |
password: Test123Test |
| 55 |
network_config: |
| 56 |
network: "projects/{{ gcp_project_number }}/global/networks/{{ resource_name }}" |
| 57 |
project: "{{ gcp_project }}" |
| 58 |
auth_kind: "{{ gcp_cred_kind }}" |
| 59 |
service_account_file: "{{ gcp_cred_file }}" |
| 60 |
register: _primary |
| 61 |
|
| 62 |
- name: Create an instance in primary cluster |
| 63 |
google.cloud.gcp_alloydb_instance: |
| 64 |
instance_id: "{{ resource_name }}" |
| 65 |
state: present |
| 66 |
instance_type: PRIMARY |
| 67 |
cluster: "{{ _primary }}" |
| 68 |
database_flags: |
| 69 |
password.enforce_complexity: "on" |
| 70 |
password.min_uppercase_letters: "1" |
| 71 |
password.min_numerical_chars: "1" |
| 72 |
password.min_pass_length: "10" |
| 73 |
password.enforce_expiration: "on" |
| 74 |
password.expiration_in_days: "1" |
| 75 |
project: "{{ gcp_project }}" |
| 76 |
auth_kind: "{{ gcp_cred_kind }}" |
| 77 |
service_account_file: "{{ gcp_cred_file }}" |
| 78 |
register: _instance |
| 79 |
|
| 80 |
- name: Run assertions |
| 81 |
ansible.builtin.assert: |
| 82 |
that: |
| 83 |
- _primary.changed == true |
| 84 |
- _instance.changed == true |
| 85 |
|
| 86 |
always: |
| 87 |
- name: Delete instance |
| 88 |
google.cloud.gcp_alloydb_instance: |
| 89 |
instance_id: "{{ resource_name }}" |
| 90 |
state: absent |
| 91 |
instance_type: PRIMARY |
| 92 |
cluster: |
| 93 |
name: "projects/{{ gcp_project }}/locations/us-central1/clusters/{{ resource_name }}-primary" |
| 94 |
project: "{{ gcp_project }}" |
| 95 |
auth_kind: "{{ gcp_cred_kind }}" |
| 96 |
service_account_file: "{{ gcp_cred_file }}" |
| 97 |
|
| 98 |
- name: Delete primary cluster |
| 99 |
google.cloud.gcp_alloydb_cluster: |
| 100 |
cluster_id: "{{ resource_name }}-primary" |
| 101 |
state: absent |
| 102 |
location: us-central1 |
| 103 |
project: "{{ gcp_project }}" |
| 104 |
auth_kind: "{{ gcp_cred_kind }}" |
| 105 |
service_account_file: "{{ gcp_cred_file }}" |
| 106 |
|
| 107 |
- name: Delete peering range |
| 108 |
google.cloud.gcp_compute_global_address: |
| 109 |
name: "{{ resource_name }}-peering" |
| 110 |
state: absent |
| 111 |
address_type: INTERNAL |
| 112 |
prefix_length: 16 |
| 113 |
purpose: VPC_PEERING |
| 114 |
network: "{{ _network }}" |
| 115 |
project: "{{ gcp_project }}" |
| 116 |
auth_kind: "{{ gcp_cred_kind }}" |
| 117 |
service_account_file: "{{ gcp_cred_file }}" |
| 118 |
|
| 119 |
always: |
| 120 |
- name: Destroy test network |
| 121 |
google.cloud.gcp_compute_network: |
| 122 |
name: "{{ resource_name }}" |
| 123 |
state: absent |
| 124 |
project: "{{ gcp_project }}" |
| 125 |
auth_kind: "{{ gcp_cred_kind }}" |
| 126 |
service_account_file: "{{ gcp_cred_file }}" |