| 1 |
--- |
| 2 |
# ---------------------------------------------------------------------------- |
| 3 |
# |
| 4 |
# *** AUTO GENERATED CODE *** Type: MMv1 *** |
| 5 |
# |
| 6 |
# ---------------------------------------------------------------------------- |
| 7 |
# |
| 8 |
# This file is automatically generated by Magic Modules and manual |
| 9 |
# changes will be clobbered when the file is regenerated. |
| 10 |
# |
| 11 |
# Please read more about how to change this file at |
| 12 |
# https://www.github.com/GoogleCloudPlatform/magic-modules |
| 13 |
# |
| 14 |
# ---------------------------------------------------------------------------- |
| 15 |
# Pre-test setup |
| 16 |
- name: Create a network |
| 17 |
google.cloud.gcp_compute_network: |
| 18 |
name: network-instance |
| 19 |
project: "{{ gcp_project }}" |
| 20 |
auth_kind: "{{ gcp_cred_kind }}" |
| 21 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 22 |
auto_create_subnetworks: true |
| 23 |
state: present |
| 24 |
register: network |
| 25 |
- name: Delete a instance |
| 26 |
google.cloud.gcp_redis_instance: |
| 27 |
name: instance37 |
| 28 |
tier: STANDARD_HA |
| 29 |
memory_size_gb: 1 |
| 30 |
region: us-central1 |
| 31 |
location_id: us-central1-a |
| 32 |
redis_version: REDIS_3_2 |
| 33 |
display_name: Ansible Test Instance |
| 34 |
reserved_ip_range: 192.168.0.0/29 |
| 35 |
labels: |
| 36 |
my_key: my_val |
| 37 |
other_key: other_val |
| 38 |
project: "{{ gcp_project }}" |
| 39 |
auth_kind: "{{ gcp_cred_kind }}" |
| 40 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 41 |
state: absent |
| 42 |
# ---------------------------------------------------------- |
| 43 |
- name: Create a instance |
| 44 |
google.cloud.gcp_redis_instance: |
| 45 |
name: instance37 |
| 46 |
tier: STANDARD_HA |
| 47 |
memory_size_gb: 1 |
| 48 |
region: us-central1 |
| 49 |
location_id: us-central1-a |
| 50 |
redis_version: REDIS_3_2 |
| 51 |
display_name: Ansible Test Instance |
| 52 |
reserved_ip_range: 192.168.0.0/29 |
| 53 |
labels: |
| 54 |
my_key: my_val |
| 55 |
other_key: other_val |
| 56 |
project: "{{ gcp_project }}" |
| 57 |
auth_kind: "{{ gcp_cred_kind }}" |
| 58 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 59 |
state: present |
| 60 |
register: result |
| 61 |
- name: Assert changed is true |
| 62 |
ansible.builtin.assert: |
| 63 |
that: |
| 64 |
- result.changed == true |
| 65 |
- name: Verify that instance was created |
| 66 |
google.cloud.gcp_redis_instance_info: |
| 67 |
region: us-central1 |
| 68 |
project: "{{ gcp_project }}" |
| 69 |
auth_kind: "{{ gcp_cred_kind }}" |
| 70 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 71 |
scopes: |
| 72 |
- https://www.googleapis.com/auth/cloud-platform |
| 73 |
register: results |
| 74 |
- name: Verify that command succeeded |
| 75 |
ansible.builtin.assert: |
| 76 |
that: |
| 77 |
- results['resources'] | map(attribute='name') | select("match", ".*instance37.*") | list | length == 1 |
| 78 |
# ---------------------------------------------------------------------------- |
| 79 |
- name: Create a instance that already exists |
| 80 |
google.cloud.gcp_redis_instance: |
| 81 |
name: instance37 |
| 82 |
tier: STANDARD_HA |
| 83 |
memory_size_gb: 1 |
| 84 |
region: us-central1 |
| 85 |
location_id: us-central1-a |
| 86 |
redis_version: REDIS_3_2 |
| 87 |
display_name: Ansible Test Instance |
| 88 |
reserved_ip_range: 192.168.0.0/29 |
| 89 |
labels: |
| 90 |
my_key: my_val |
| 91 |
other_key: other_val |
| 92 |
project: "{{ gcp_project }}" |
| 93 |
auth_kind: "{{ gcp_cred_kind }}" |
| 94 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 95 |
state: present |
| 96 |
register: result |
| 97 |
- name: Assert changed is false |
| 98 |
ansible.builtin.assert: |
| 99 |
that: |
| 100 |
- result.changed == false |
| 101 |
# ---------------------------------------------------------- |
| 102 |
- name: Delete a instance |
| 103 |
google.cloud.gcp_redis_instance: |
| 104 |
name: instance37 |
| 105 |
tier: STANDARD_HA |
| 106 |
memory_size_gb: 1 |
| 107 |
region: us-central1 |
| 108 |
location_id: us-central1-a |
| 109 |
redis_version: REDIS_3_2 |
| 110 |
display_name: Ansible Test Instance |
| 111 |
reserved_ip_range: 192.168.0.0/29 |
| 112 |
labels: |
| 113 |
my_key: my_val |
| 114 |
other_key: other_val |
| 115 |
project: "{{ gcp_project }}" |
| 116 |
auth_kind: "{{ gcp_cred_kind }}" |
| 117 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 118 |
state: absent |
| 119 |
register: result |
| 120 |
- name: Assert changed is true |
| 121 |
ansible.builtin.assert: |
| 122 |
that: |
| 123 |
- result.changed == true |
| 124 |
- name: Verify that instance was deleted |
| 125 |
google.cloud.gcp_redis_instance_info: |
| 126 |
region: us-central1 |
| 127 |
project: "{{ gcp_project }}" |
| 128 |
auth_kind: "{{ gcp_cred_kind }}" |
| 129 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 130 |
scopes: |
| 131 |
- https://www.googleapis.com/auth/cloud-platform |
| 132 |
register: results |
| 133 |
- name: Verify that command succeeded |
| 134 |
ansible.builtin.assert: |
| 135 |
that: |
| 136 |
- results['resources'] | map(attribute='name') | select("match", ".*instance37.*") | list | length == 0 |
| 137 |
# ---------------------------------------------------------------------------- |
| 138 |
- name: Delete a instance that does not exist |
| 139 |
google.cloud.gcp_redis_instance: |
| 140 |
name: instance37 |
| 141 |
tier: STANDARD_HA |
| 142 |
memory_size_gb: 1 |
| 143 |
region: us-central1 |
| 144 |
location_id: us-central1-a |
| 145 |
redis_version: REDIS_3_2 |
| 146 |
display_name: Ansible Test Instance |
| 147 |
reserved_ip_range: 192.168.0.0/29 |
| 148 |
labels: |
| 149 |
my_key: my_val |
| 150 |
other_key: other_val |
| 151 |
project: "{{ gcp_project }}" |
| 152 |
auth_kind: "{{ gcp_cred_kind }}" |
| 153 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 154 |
state: absent |
| 155 |
register: result |
| 156 |
- name: Assert changed is false |
| 157 |
ansible.builtin.assert: |
| 158 |
that: |
| 159 |
- result.changed == false |
| 160 |
# --------------------------------------------------------- |
| 161 |
# Post-test teardown |
| 162 |
# If errors happen, don't crash the playbook! |
| 163 |
- name: Delete a network |
| 164 |
google.cloud.gcp_compute_network: |
| 165 |
name: network-instance |
| 166 |
project: "{{ gcp_project }}" |
| 167 |
auth_kind: "{{ gcp_cred_kind }}" |
| 168 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 169 |
auto_create_subnetworks: true |
| 170 |
state: absent |
| 171 |
register: network |
| 172 |
ignore_errors: true |