|
11 | 11 | success_msg: | |
12 | 12 | Running task file {{ procedure_task_file }} |
13 | 13 |
|
14 | | -- name: Run procedure {{ procedure_task_file }} |
15 | | - ansible.builtin.include_tasks: "procedures/{{ procedure_task_file }}" |
| 14 | +- name: Run day2ops procedure {{ procedure_task_file }} (no verification) |
| 15 | + vars: |
| 16 | + procedure: "{{ procedure_task_file | regex_replace('\\.yml$', '') }}" |
| 17 | + report_path: "{{ report_dir }}/{{ day2ops_report_filename }}" |
| 18 | + block: |
| 19 | + |
| 20 | + - name: Create entry on report |
| 21 | + community.general.xml: |
| 22 | + path: "{{ report_path }}" |
| 23 | + xpath: /shiftstack-day2ops/{{ procedure }} |
| 24 | + |
| 25 | + - name: Store start time on report for {{ procedure }} |
| 26 | + community.general.xml: |
| 27 | + path: "{{ report_path }}" |
| 28 | + xpath: /shiftstack-day2ops/{{ procedure }} |
| 29 | + attribute: start_time |
| 30 | + value: "{{ lookup('pipe', 'date +%Y-%m-%dT%H:%M:%S') }}" |
| 31 | + |
| 32 | + - name: Run the day2ops procedure |
| 33 | + ansible.builtin.include_tasks: "procedures/{{ procedure_task_file }}" |
| 34 | + |
| 35 | + - name: Write result:SUCCESS on report for {{ procedure }} |
| 36 | + community.general.xml: |
| 37 | + path: "{{ report_path }}" |
| 38 | + xpath: /shiftstack-day2ops/{{ procedure }} |
| 39 | + attribute: result |
| 40 | + value: PASSED |
| 41 | + |
| 42 | + rescue: |
| 43 | + - name: Write result:FAILED on report for {{ procedure }} |
| 44 | + community.general.xml: |
| 45 | + path: "{{ report_path }}" |
| 46 | + xpath: /shiftstack-day2ops/{{ procedure }} |
| 47 | + attribute: result |
| 48 | + value: FAILED |
| 49 | + |
| 50 | + - name: Write failed_task on report for {{ procedure }} |
| 51 | + community.general.xml: |
| 52 | + path: "{{ report_path }}" |
| 53 | + xpath: /shiftstack-day2ops/{{ procedure }} |
| 54 | + attribute: failed_task |
| 55 | + value: "{{ (ansible_failed_task is defined) | ternary(ansible_failed_task.name, 'UNKNOWN') }}" |
| 56 | + |
| 57 | + - name: Run must-gather |
| 58 | + ansible.builtin.include_role: |
| 59 | + name: tools_must-gather |
| 60 | + vars: |
| 61 | + must_gather_suffix: "{{ procedure }}" |
| 62 | + |
| 63 | + - name: Fail the playbook in a case of failure |
| 64 | + ansible.builtin.fail: |
| 65 | + msg: > |
| 66 | + Failed! See logs and must-gather for more information. |
| 67 | + The {{ procedure_task_file }} task file failed. |
| 68 | +
|
| 69 | + always: |
| 70 | + - name: Write end_time on report for {{ procedure }} |
| 71 | + community.general.xml: |
| 72 | + path: "{{ report_path }}" |
| 73 | + xpath: /shiftstack-day2ops/{{ procedure }} |
| 74 | + attribute: end_time |
| 75 | + value: "{{ lookup('pipe', 'date +%Y-%m-%dT%H:%M:%S') }}" |
0 commit comments