Skip to content

Commit dcae49a

Browse files
eshulman2claude
andcommitted
Add block/rescue/always to run_procedure_no_verify for error handling
Keep XML report entries, must-gather collection on failure, and timing from run_procedure.yml while omitting the verification role call. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Change-Id: Ia453f0408c35400eed6d343105f8d1cb449d7990
1 parent d9a7612 commit dcae49a

3 files changed

Lines changed: 320 additions & 259 deletions

File tree

collection/stages/roles/day2ops/tasks/run_procedure_no_verify.yml

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,65 @@
1111
success_msg: |
1212
Running task file {{ procedure_task_file }}
1313
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

Comments
 (0)