| 1 |
--- |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
- name: Delete a job |
| 17 |
google.cloud.gcp_cloudscheduler_job: |
| 18 |
name: job |
| 19 |
region: us-central1 |
| 20 |
schedule: "*/4 * * * *" |
| 21 |
description: test app engine job |
| 22 |
time_zone: Europe/London |
| 23 |
attempt_deadline: 320s |
| 24 |
app_engine_http_target: |
| 25 |
http_method: POST |
| 26 |
app_engine_routing: |
| 27 |
service: web |
| 28 |
version: prod |
| 29 |
instance: my-instance-001 |
| 30 |
relative_uri: /ping |
| 31 |
project: "{{ gcp_project }}" |
| 32 |
auth_kind: "{{ gcp_cred_kind }}" |
| 33 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 34 |
state: absent |
| 35 |
|
| 36 |
- name: Create a job |
| 37 |
google.cloud.gcp_cloudscheduler_job: |
| 38 |
name: job |
| 39 |
region: us-central1 |
| 40 |
schedule: "*/4 * * * *" |
| 41 |
description: test app engine job |
| 42 |
time_zone: Europe/London |
| 43 |
attempt_deadline: 320s |
| 44 |
app_engine_http_target: |
| 45 |
http_method: POST |
| 46 |
app_engine_routing: |
| 47 |
service: web |
| 48 |
version: prod |
| 49 |
instance: my-instance-001 |
| 50 |
relative_uri: /ping |
| 51 |
project: "{{ gcp_project }}" |
| 52 |
auth_kind: "{{ gcp_cred_kind }}" |
| 53 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 54 |
state: present |
| 55 |
register: result |
| 56 |
- name: Assert changed is true |
| 57 |
ansible.builtin.assert: |
| 58 |
that: |
| 59 |
- result.changed == true |
| 60 |
- name: Verify that job was created |
| 61 |
google.cloud.gcp_cloudscheduler_job_info: |
| 62 |
region: us-central1 |
| 63 |
project: "{{ gcp_project }}" |
| 64 |
auth_kind: "{{ gcp_cred_kind }}" |
| 65 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 66 |
scopes: |
| 67 |
- https://www.googleapis.com/auth/cloud-platform |
| 68 |
register: results |
| 69 |
- name: Verify that command succeeded |
| 70 |
ansible.builtin.assert: |
| 71 |
that: |
| 72 |
- results['resources'] | map(attribute='name') | select("match", ".*job.*") | list | length == 1 |
| 73 |
|
| 74 |
- name: Create a job that already exists |
| 75 |
google.cloud.gcp_cloudscheduler_job: |
| 76 |
name: job |
| 77 |
region: us-central1 |
| 78 |
schedule: "*/4 * * * *" |
| 79 |
description: test app engine job |
| 80 |
time_zone: Europe/London |
| 81 |
attempt_deadline: 320s |
| 82 |
app_engine_http_target: |
| 83 |
http_method: POST |
| 84 |
app_engine_routing: |
| 85 |
service: web |
| 86 |
version: prod |
| 87 |
instance: my-instance-001 |
| 88 |
relative_uri: /ping |
| 89 |
project: "{{ gcp_project }}" |
| 90 |
auth_kind: "{{ gcp_cred_kind }}" |
| 91 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 92 |
state: present |
| 93 |
register: result |
| 94 |
- name: Assert changed is false |
| 95 |
ansible.builtin.assert: |
| 96 |
that: |
| 97 |
- result.changed == false |
| 98 |
|
| 99 |
- name: Delete a job |
| 100 |
google.cloud.gcp_cloudscheduler_job: |
| 101 |
name: job |
| 102 |
region: us-central1 |
| 103 |
schedule: "*/4 * * * *" |
| 104 |
description: test app engine job |
| 105 |
time_zone: Europe/London |
| 106 |
attempt_deadline: 320s |
| 107 |
app_engine_http_target: |
| 108 |
http_method: POST |
| 109 |
app_engine_routing: |
| 110 |
service: web |
| 111 |
version: prod |
| 112 |
instance: my-instance-001 |
| 113 |
relative_uri: /ping |
| 114 |
project: "{{ gcp_project }}" |
| 115 |
auth_kind: "{{ gcp_cred_kind }}" |
| 116 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 117 |
state: absent |
| 118 |
register: result |
| 119 |
- name: Assert changed is true |
| 120 |
ansible.builtin.assert: |
| 121 |
that: |
| 122 |
- result.changed == true |
| 123 |
- name: Verify that job was deleted |
| 124 |
google.cloud.gcp_cloudscheduler_job_info: |
| 125 |
region: us-central1 |
| 126 |
project: "{{ gcp_project }}" |
| 127 |
auth_kind: "{{ gcp_cred_kind }}" |
| 128 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 129 |
scopes: |
| 130 |
- https://www.googleapis.com/auth/cloud-platform |
| 131 |
register: results |
| 132 |
- name: Verify that command succeeded |
| 133 |
ansible.builtin.assert: |
| 134 |
that: |
| 135 |
- results['resources'] | map(attribute='name') | select("match", ".*job.*") | list | length == 0 |
| 136 |
|
| 137 |
- name: Delete a job that does not exist |
| 138 |
google.cloud.gcp_cloudscheduler_job: |
| 139 |
name: job |
| 140 |
region: us-central1 |
| 141 |
schedule: "*/4 * * * *" |
| 142 |
description: test app engine job |
| 143 |
time_zone: Europe/London |
| 144 |
attempt_deadline: 320s |
| 145 |
app_engine_http_target: |
| 146 |
http_method: POST |
| 147 |
app_engine_routing: |
| 148 |
service: web |
| 149 |
version: prod |
| 150 |
instance: my-instance-001 |
| 151 |
relative_uri: /ping |
| 152 |
project: "{{ gcp_project }}" |
| 153 |
auth_kind: "{{ gcp_cred_kind }}" |
| 154 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 155 |
state: absent |
| 156 |
register: result |
| 157 |
- name: Assert changed is false |
| 158 |
ansible.builtin.assert: |
| 159 |
that: |
| 160 |
- result.changed == false |