| 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: Delete a disk |
| 17 |
google.cloud.gcp_compute_disk: |
| 18 |
name: "{{ resource_name }}" |
| 19 |
size_gb: 50 |
| 20 |
disk_encryption_key: |
| 21 |
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= |
| 22 |
zone: us-central1-a |
| 23 |
project: "{{ gcp_project }}" |
| 24 |
auth_kind: "{{ gcp_cred_kind }}" |
| 25 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 26 |
state: absent |
| 27 |
# ---------------------------------------------------------- |
| 28 |
- name: Create a disk |
| 29 |
google.cloud.gcp_compute_disk: |
| 30 |
name: "{{ resource_name }}" |
| 31 |
size_gb: 50 |
| 32 |
disk_encryption_key: |
| 33 |
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= |
| 34 |
zone: us-central1-a |
| 35 |
project: "{{ gcp_project }}" |
| 36 |
auth_kind: "{{ gcp_cred_kind }}" |
| 37 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 38 |
state: present |
| 39 |
register: result |
| 40 |
- name: Assert changed is true |
| 41 |
ansible.builtin.assert: |
| 42 |
that: |
| 43 |
- result.changed == true |
| 44 |
- name: Verify that disk was created |
| 45 |
google.cloud.gcp_compute_disk_info: |
| 46 |
filters: |
| 47 |
- name = {{ resource_name }} |
| 48 |
zone: us-central1-a |
| 49 |
project: "{{ gcp_project }}" |
| 50 |
auth_kind: "{{ gcp_cred_kind }}" |
| 51 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 52 |
scopes: |
| 53 |
- https://www.googleapis.com/auth/compute |
| 54 |
register: results |
| 55 |
- name: Verify that command succeeded |
| 56 |
ansible.builtin.assert: |
| 57 |
that: |
| 58 |
- results['resources'] | length == 1 |
| 59 |
# ---------------------------------------------------------------------------- |
| 60 |
- name: Create a disk that already exists |
| 61 |
google.cloud.gcp_compute_disk: |
| 62 |
name: "{{ resource_name }}" |
| 63 |
size_gb: 50 |
| 64 |
disk_encryption_key: |
| 65 |
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= |
| 66 |
zone: us-central1-a |
| 67 |
project: "{{ gcp_project }}" |
| 68 |
auth_kind: "{{ gcp_cred_kind }}" |
| 69 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 70 |
state: present |
| 71 |
register: result |
| 72 |
- name: Assert changed is false |
| 73 |
ansible.builtin.assert: |
| 74 |
that: |
| 75 |
- result.changed == false |
| 76 |
# ---------------------------------------------------------- |
| 77 |
- name: Delete a disk |
| 78 |
google.cloud.gcp_compute_disk: |
| 79 |
name: "{{ resource_name }}" |
| 80 |
size_gb: 50 |
| 81 |
disk_encryption_key: |
| 82 |
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= |
| 83 |
zone: us-central1-a |
| 84 |
project: "{{ gcp_project }}" |
| 85 |
auth_kind: "{{ gcp_cred_kind }}" |
| 86 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 87 |
state: absent |
| 88 |
register: result |
| 89 |
- name: Assert changed is true |
| 90 |
ansible.builtin.assert: |
| 91 |
that: |
| 92 |
- result.changed == true |
| 93 |
- name: Verify that disk was deleted |
| 94 |
google.cloud.gcp_compute_disk_info: |
| 95 |
filters: |
| 96 |
- name = {{ resource_name }} |
| 97 |
zone: us-central1-a |
| 98 |
project: "{{ gcp_project }}" |
| 99 |
auth_kind: "{{ gcp_cred_kind }}" |
| 100 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 101 |
scopes: |
| 102 |
- https://www.googleapis.com/auth/compute |
| 103 |
register: results |
| 104 |
- name: Verify that command succeeded |
| 105 |
ansible.builtin.assert: |
| 106 |
that: |
| 107 |
- results['resources'] | length == 0 |
| 108 |
# ---------------------------------------------------------------------------- |
| 109 |
- name: Delete a disk that does not exist |
| 110 |
google.cloud.gcp_compute_disk: |
| 111 |
name: "{{ resource_name }}" |
| 112 |
size_gb: 50 |
| 113 |
disk_encryption_key: |
| 114 |
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= |
| 115 |
zone: us-central1-a |
| 116 |
project: "{{ gcp_project }}" |
| 117 |
auth_kind: "{{ gcp_cred_kind }}" |
| 118 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 119 |
state: absent |
| 120 |
register: result |
| 121 |
- name: Assert changed is false |
| 122 |
ansible.builtin.assert: |
| 123 |
that: |
| 124 |
- result.changed == false |