| 1 |
--- |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
- name: Delete a cluster |
| 17 |
google.cloud.gcp_container_cluster: |
| 18 |
name: my-cluster |
| 19 |
initial_node_count: 2 |
| 20 |
node_config: |
| 21 |
machine_type: n1-standard-4 |
| 22 |
disk_size_gb: 500 |
| 23 |
location: us-central1-a |
| 24 |
project: "{{ gcp_project }}" |
| 25 |
auth_kind: serviceaccount |
| 26 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 27 |
state: absent |
| 28 |
|
| 29 |
- name: Create a cluster |
| 30 |
google.cloud.gcp_container_cluster: |
| 31 |
name: my-cluster |
| 32 |
initial_node_count: 2 |
| 33 |
node_config: |
| 34 |
machine_type: n1-standard-4 |
| 35 |
disk_size_gb: 500 |
| 36 |
location: us-central1-a |
| 37 |
project: "{{ gcp_project }}" |
| 38 |
auth_kind: serviceaccount |
| 39 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 40 |
state: present |
| 41 |
register: result |
| 42 |
- name: Assert changed is true |
| 43 |
ansible.builtin.assert: |
| 44 |
that: |
| 45 |
- result.changed == true |
| 46 |
- name: Verify that cluster was created |
| 47 |
google.cloud.gcp_container_cluster_info: |
| 48 |
location: us-central1-a |
| 49 |
project: "{{ gcp_project }}" |
| 50 |
auth_kind: serviceaccount |
| 51 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 52 |
scopes: |
| 53 |
- https://www.googleapis.com/auth/cloud-platform |
| 54 |
register: results |
| 55 |
- name: Verify that command succeeded |
| 56 |
ansible.builtin.assert: |
| 57 |
that: |
| 58 |
- results['resources'] | map(attribute='name') | select("match", ".*my-cluster.*") | list | length == 1 |
| 59 |
|
| 60 |
- name: Create a cluster that already exists |
| 61 |
google.cloud.gcp_container_cluster: |
| 62 |
name: my-cluster |
| 63 |
initial_node_count: 2 |
| 64 |
node_config: |
| 65 |
machine_type: n1-standard-4 |
| 66 |
disk_size_gb: 500 |
| 67 |
location: us-central1-a |
| 68 |
project: "{{ gcp_project }}" |
| 69 |
auth_kind: serviceaccount |
| 70 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 71 |
state: present |
| 72 |
register: result |
| 73 |
- name: Assert changed is false |
| 74 |
ansible.builtin.assert: |
| 75 |
that: |
| 76 |
- result.changed == false |
| 77 |
|
| 78 |
- name: Delete a cluster |
| 79 |
google.cloud.gcp_container_cluster: |
| 80 |
name: my-cluster |
| 81 |
initial_node_count: 2 |
| 82 |
node_config: |
| 83 |
machine_type: n1-standard-4 |
| 84 |
disk_size_gb: 500 |
| 85 |
location: us-central1-a |
| 86 |
project: "{{ gcp_project }}" |
| 87 |
auth_kind: serviceaccount |
| 88 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 89 |
state: absent |
| 90 |
register: result |
| 91 |
- name: Assert changed is true |
| 92 |
ansible.builtin.assert: |
| 93 |
that: |
| 94 |
- result.changed == true |
| 95 |
- name: Verify that cluster was deleted |
| 96 |
google.cloud.gcp_container_cluster_info: |
| 97 |
location: 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/cloud-platform |
| 103 |
register: results |
| 104 |
- name: Verify that command succeeded |
| 105 |
ansible.builtin.assert: |
| 106 |
that: |
| 107 |
- results['resources'] | map(attribute='name') | select("match", ".*my-cluster.*") | list | length == 0 |
| 108 |
|
| 109 |
- name: Delete a cluster that does not exist |
| 110 |
google.cloud.gcp_container_cluster: |
| 111 |
name: my-cluster |
| 112 |
initial_node_count: 2 |
| 113 |
node_config: |
| 114 |
machine_type: n1-standard-4 |
| 115 |
disk_size_gb: 500 |
| 116 |
location: us-central1-a |
| 117 |
project: "{{ gcp_project }}" |
| 118 |
auth_kind: serviceaccount |
| 119 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 120 |
state: absent |
| 121 |
register: result |
| 122 |
- name: Assert changed is false |
| 123 |
ansible.builtin.assert: |
| 124 |
that: |
| 125 |
- result.changed == false |