| 1 |
--- |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
- name: Delete a config |
| 17 |
google.cloud.gcp_runtimeconfig_config: |
| 18 |
name: "{{ resource_name }}" |
| 19 |
description: My config |
| 20 |
project: "{{ gcp_project }}" |
| 21 |
auth_kind: "{{ gcp_cred_kind }}" |
| 22 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 23 |
state: absent |
| 24 |
|
| 25 |
- name: Create a config |
| 26 |
google.cloud.gcp_runtimeconfig_config: |
| 27 |
name: "{{ resource_name }}" |
| 28 |
description: My config |
| 29 |
project: "{{ gcp_project }}" |
| 30 |
auth_kind: "{{ gcp_cred_kind }}" |
| 31 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 32 |
state: present |
| 33 |
register: result |
| 34 |
- name: Assert changed is true |
| 35 |
ansible.builtin.assert: |
| 36 |
that: |
| 37 |
- result.changed == true |
| 38 |
- name: Verify that config was created |
| 39 |
google.cloud.gcp_runtimeconfig_config_info: |
| 40 |
project: "{{ gcp_project }}" |
| 41 |
auth_kind: "{{ gcp_cred_kind }}" |
| 42 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 43 |
scopes: |
| 44 |
- https://www.googleapis.com/auth/cloudruntimeconfig |
| 45 |
register: results |
| 46 |
- name: Verify that command succeeded |
| 47 |
ansible.builtin.assert: |
| 48 |
that: |
| 49 |
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 |
| 50 |
|
| 51 |
- name: Create a config that already exists |
| 52 |
google.cloud.gcp_runtimeconfig_config: |
| 53 |
name: "{{ resource_name }}" |
| 54 |
description: My config |
| 55 |
project: "{{ gcp_project }}" |
| 56 |
auth_kind: "{{ gcp_cred_kind }}" |
| 57 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 58 |
state: present |
| 59 |
register: result |
| 60 |
- name: Assert changed is false |
| 61 |
ansible.builtin.assert: |
| 62 |
that: |
| 63 |
- result.changed == false |
| 64 |
|
| 65 |
- name: Delete a config |
| 66 |
google.cloud.gcp_runtimeconfig_config: |
| 67 |
name: "{{ resource_name }}" |
| 68 |
description: My config |
| 69 |
project: "{{ gcp_project }}" |
| 70 |
auth_kind: "{{ gcp_cred_kind }}" |
| 71 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 72 |
state: absent |
| 73 |
register: result |
| 74 |
- name: Assert changed is true |
| 75 |
ansible.builtin.assert: |
| 76 |
that: |
| 77 |
- result.changed == true |
| 78 |
- name: Verify that config was deleted |
| 79 |
google.cloud.gcp_runtimeconfig_config_info: |
| 80 |
project: "{{ gcp_project }}" |
| 81 |
auth_kind: "{{ gcp_cred_kind }}" |
| 82 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 83 |
scopes: |
| 84 |
- https://www.googleapis.com/auth/cloudruntimeconfig |
| 85 |
register: results |
| 86 |
- name: Verify that command succeeded |
| 87 |
ansible.builtin.assert: |
| 88 |
that: |
| 89 |
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 |
| 90 |
|
| 91 |
- name: Delete a config that does not exist |
| 92 |
google.cloud.gcp_runtimeconfig_config: |
| 93 |
name: "{{ resource_name }}" |
| 94 |
description: My config |
| 95 |
project: "{{ gcp_project }}" |
| 96 |
auth_kind: "{{ gcp_cred_kind }}" |
| 97 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 98 |
state: absent |
| 99 |
register: result |
| 100 |
- name: Assert changed is false |
| 101 |
ansible.builtin.assert: |
| 102 |
that: |
| 103 |
- result.changed == false |