|
| 1 | +# (c) Copyright IBM Corp. 2024 |
| 2 | +# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0) |
| 3 | +--- |
| 4 | +- name: Deprovision with job name |
| 5 | + hosts: 'all' |
| 6 | + gather_facts: false |
| 7 | + environment: "{{ environment_vars }}" |
| 8 | + |
| 9 | + module_defaults: |
| 10 | + group/ibm.ibm_zos_cics.region: |
| 11 | + cics_data_sets: |
| 12 | + template: "{{ cics_install_path }}.<< lib_name >>" |
| 13 | + region_data_sets: |
| 14 | + template: "{{ region_data_set_path }}.<< data_set_name >>" |
| 15 | + space_primary: 2 |
| 16 | + space_secondary: 1 |
| 17 | + space_type: "M" |
| 18 | + |
| 19 | + tasks: |
| 20 | + - name: Stop no args and job name |
| 21 | + block: |
| 22 | + - name: Create data sets |
| 23 | + ansible.builtin.import_tasks: ../repeatable_tasks/data_sets.yml |
| 24 | + vars: |
| 25 | + data_set_state: initial |
| 26 | + |
| 27 | + - name: Start CICS (1) |
| 28 | + ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml |
| 29 | + |
| 30 | + - name: Stop with no args |
| 31 | + ibm.ibm_zos_cics.stop_region: |
| 32 | + register: stop_result |
| 33 | + timeout: 300 |
| 34 | + ignore_errors: true |
| 35 | + |
| 36 | + - name: Assert stop with no args failed |
| 37 | + ansible.builtin.assert: |
| 38 | + that: |
| 39 | + - stop_result.failed is true |
| 40 | + - stop_result.changed is false |
| 41 | + - "{{ stop_result.executions | length }} == 0" |
| 42 | + - stop_result.msg == "one of the following is required: job_id, job_name" |
| 43 | + |
| 44 | + - name: Stop CICS using job name |
| 45 | + ansible.builtin.import_tasks: ../repeatable_tasks/stop_region.yml |
| 46 | + vars: |
| 47 | + mode: normal |
| 48 | + jobid: false |
| 49 | + jobname: true |
| 50 | + |
| 51 | + - name: Stop job name and job id |
| 52 | + block: |
| 53 | + - name: Start CICS (2) |
| 54 | + ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml |
| 55 | + |
| 56 | + - name: Stop CICS with both name and ID |
| 57 | + ansible.builtin.import_tasks: ../repeatable_tasks/stop_region.yml |
| 58 | + vars: |
| 59 | + mode: normal |
| 60 | + jobname: true |
| 61 | + job_id: true |
| 62 | + |
| 63 | + - name: Stop job timeout |
| 64 | + block: |
| 65 | + - name: Start CICS (3) |
| 66 | + ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml |
| 67 | + |
| 68 | + - name: Issue shutdown command (with job_id and job_name) |
| 69 | + ibm.ibm_zos_cics.stop_region: |
| 70 | + job_name: "{{ start_region_applid }}" |
| 71 | + job_id: "{{ start_result.job_id }}" |
| 72 | + mode: normal |
| 73 | + timeout: 120 |
| 74 | + register: stop_result |
| 75 | + |
| 76 | + - name: Log output of stop |
| 77 | + ansible.builtin.debug: |
| 78 | + msg: "{{ stop_result }}" |
| 79 | + |
| 80 | + - name: Assert CICS stop did not fail |
| 81 | + ansible.builtin.assert: |
| 82 | + that: |
| 83 | + - stop_result.failed == false |
| 84 | + - stop_result.msg == "" |
| 85 | + - stop_result.executions[-1].return.failed == False |
| 86 | + - stop_result.executions[-1].return.output[0].content | length == 2 |
| 87 | + - "'ON OUTPUT QUEUE' in '{{ stop_result.executions[-1].return.output[0].content | join(' ') }}'" |
| 88 | + fail_msg: "CICS Region did not stop successfully" |
| 89 | + |
| 90 | + always: |
| 91 | + - name: Delete job |
| 92 | + ansible.builtin.command: |
| 93 | + cmd: "jcan P {{ start_region_applid }} {{ start_result.job_id }}" |
| 94 | + ignore_errors: true |
| 95 | + |
| 96 | + - name: Stop job no timeout |
| 97 | + block: |
| 98 | + - name: Start CICS (4) |
| 99 | + ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml |
| 100 | + |
| 101 | + - name: Issue shutdown command (with job_id and job_name) |
| 102 | + ibm.ibm_zos_cics.stop_region: |
| 103 | + job_name: "{{ start_region_applid }}" |
| 104 | + job_id: "{{ start_result.job_id }}" |
| 105 | + mode: normal |
| 106 | + timeout: -1 |
| 107 | + register: stop_result |
| 108 | + timeout: 300 |
| 109 | + |
| 110 | + - name: Log output of stop |
| 111 | + ansible.builtin.debug: |
| 112 | + msg: "{{ stop_result }}" |
| 113 | + |
| 114 | + - name: Assert CICS stop did not fail |
| 115 | + ansible.builtin.assert: |
| 116 | + that: |
| 117 | + - stop_result.failed != True |
| 118 | + - stop_result.msg == "" |
| 119 | + - stop_result.executions[-1].return.failed == False |
| 120 | + - stop_result.executions[-1].return.output[0].content | length == 2 |
| 121 | + - "'ON OUTPUT QUEUE' in '{{ stop_result.executions[-1].return.output[0].content | join(' ') }}'" |
| 122 | + fail_msg: "CICS Region did not stop successfully" |
| 123 | + |
| 124 | + - name: Stop job mismatched name and ID |
| 125 | + block: |
| 126 | + - name: Start CICS (5) |
| 127 | + ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml |
| 128 | + |
| 129 | + - name: Issue shutdown command (wrong id) |
| 130 | + ibm.ibm_zos_cics.stop_region: |
| 131 | + job_name: "{{ start_region_applid }}" |
| 132 | + job_id: "NONJOB" |
| 133 | + register: stop_result |
| 134 | + timeout: 300 |
| 135 | + ignore_errors: true |
| 136 | + |
| 137 | + - name: Log output of stop |
| 138 | + ansible.builtin.debug: |
| 139 | + msg: "{{ stop_result }}" |
| 140 | + |
| 141 | + - name: Assert CICS stop did not fail |
| 142 | + ansible.builtin.assert: |
| 143 | + that: |
| 144 | + - stop_result.failed == true |
| 145 | + - stop_result.msg == "No jobs found with name TWYD01 and ID NONJOB" |
| 146 | + |
| 147 | + - name: Issue shutdown command (wrong name) |
| 148 | + ibm.ibm_zos_cics.stop_region: |
| 149 | + job_name: "NONJOB" |
| 150 | + job_id: "{{ start_result.job_id }}" |
| 151 | + register: stop_result |
| 152 | + timeout: 300 |
| 153 | + ignore_errors: true |
| 154 | + |
| 155 | + - name: Log output of stop |
| 156 | + ansible.builtin.debug: |
| 157 | + msg: "{{ stop_result }}" |
| 158 | + |
| 159 | + - name: Assert CICS stop did not fail |
| 160 | + ansible.builtin.assert: |
| 161 | + that: |
| 162 | + - stop_result.failed == true |
| 163 | + - stop_result.msg == "No jobs found with name NONJOB and ID {{ start_result.job_id }}" |
| 164 | + always: |
| 165 | + - name: Delete job |
| 166 | + ansible.builtin.command: |
| 167 | + cmd: "jcan C {{ start_region_applid }} {{ start_result.job_id }}" |
| 168 | + ignore_errors: true |
| 169 | + |
| 170 | + - name: Stop job already stopped |
| 171 | + block: |
| 172 | + - name: Issue shutdown command with name |
| 173 | + ibm.ibm_zos_cics.stop_region: |
| 174 | + job_name: "{{ start_region_applid }}" |
| 175 | + register: stop_result |
| 176 | + - name: Assert CICS stop did not fail |
| 177 | + ansible.builtin.assert: |
| 178 | + that: |
| 179 | + - stop_result.failed == false |
| 180 | + - stop_result.changed == false |
| 181 | + - stop_result.msg == "" |
| 182 | + - name: Issue shutdown command with ID |
| 183 | + ibm.ibm_zos_cics.stop_region: |
| 184 | + job_id: "{{ start_result.job_id }}" |
| 185 | + register: stop_result |
| 186 | + - name: Assert CICS stop did not fail |
| 187 | + ansible.builtin.assert: |
| 188 | + that: |
| 189 | + - stop_result.failed == false |
| 190 | + - stop_result.changed == false |
| 191 | + - stop_result.msg == "" |
| 192 | + - name: Issue shutdown command with ID and name |
| 193 | + ibm.ibm_zos_cics.stop_region: |
| 194 | + job_id: "{{ start_result.job_id }}" |
| 195 | + job_name: "{{ start_region_applid }}" |
| 196 | + register: stop_result |
| 197 | + - name: Assert CICS stop did not fail |
| 198 | + ansible.builtin.assert: |
| 199 | + that: |
| 200 | + - stop_result.failed == false |
| 201 | + - stop_result.changed == false |
| 202 | + - stop_result.msg == "" |
| 203 | + |
| 204 | + - name: Issue shutdown command with mismatched name and id (wrong name) |
| 205 | + ibm.ibm_zos_cics.stop_region: |
| 206 | + job_id: "{{ start_result.job_id }}" |
| 207 | + job_name: "NONJOB" |
| 208 | + register: stop_result |
| 209 | + ignore_errors: true |
| 210 | + - name: Assert CICS stop did not fail |
| 211 | + ansible.builtin.assert: |
| 212 | + that: |
| 213 | + - stop_result.failed == true |
| 214 | + - stop_result.changed == false |
| 215 | + - stop_result.msg == "No jobs found with name NONJOB and ID {{ start_result.job_id }}" |
| 216 | + - name: Issue shutdown command with mismatched name and id (wrong id) |
| 217 | + ibm.ibm_zos_cics.stop_region: |
| 218 | + job_id: "NONJOB" |
| 219 | + job_name: "{{ start_region_applid }}" |
| 220 | + register: stop_result |
| 221 | + ignore_errors: true |
| 222 | + - name: Assert CICS stop did not fail |
| 223 | + ansible.builtin.assert: |
| 224 | + that: |
| 225 | + - stop_result.failed == true |
| 226 | + - stop_result.changed == false |
| 227 | + - stop_result.msg == "No jobs found with name {{ start_region_applid }} and ID NONJOB" |
| 228 | + |
| 229 | + always: |
| 230 | + - name: Delete job |
| 231 | + ansible.builtin.command: |
| 232 | + cmd: "jcan P {{ start_region_applid }} {{ start_result.job_id }}" |
| 233 | + ignore_errors: true |
| 234 | + - name: Delete data sets |
| 235 | + ansible.builtin.import_tasks: ../repeatable_tasks/data_sets.yml |
| 236 | + vars: |
| 237 | + data_set_state: absent |
0 commit comments