|
22 | 22 | include_tasks: tasks/run_role_with_clear_facts.yml |
23 | 23 | vars: |
24 | 24 | __sr_public: true |
| 25 | + __kdump_write_log_file: true |
25 | 26 |
|
26 | | - # look for the exact module invocation, not some other message that might contain the string |
27 | | - - name: Check system journal contains role fingerprints |
| 27 | + - name: Get fingerprint entries from journal |
28 | 28 | ansible.builtin.shell: |
29 | 29 | executable: /bin/bash |
30 | 30 | cmd: >- |
31 | 31 | set -eo pipefail; |
32 | 32 | journalctl --since "{{ __journal_start_time }}" --no-pager | |
33 | | - grep -v " Invoked with" | grep "sr_fingerprint.*begin system_role:kdump" || |
34 | | - { echo ERROR: BEGIN fingerprint not found; exit 1; }; |
35 | | - journalctl --since "{{ __journal_start_time }}" --no-pager | |
36 | | - grep -v " Invoked with" | grep "sr_fingerprint.*success system_role:kdump" || |
37 | | - { echo ERROR: SUCCESS fingerprint not found; exit 1; } |
| 33 | + grep -v " Invoked with" | |
| 34 | + grep "sr_fingerprint.*role_name=kdump" |
| 35 | + register: __register_journal_fingerprints |
38 | 36 | changed_when: false |
39 | 37 | when: __register_dev_log.stat.exists |
40 | 38 |
|
| 39 | + - name: Check that the log file was written |
| 40 | + ansible.builtin.slurp: |
| 41 | + path: /var/log/sysroles.jsonl |
| 42 | + register: __register_log_file |
| 43 | + |
| 44 | + - name: Verify log file and journal fingerprints |
| 45 | + when: __register_dev_log.stat.exists |
| 46 | + vars: |
| 47 | + __journal_lines: "{{ __register_journal_fingerprints.stdout_lines }}" |
| 48 | + __journal_begin: "{{ __journal_lines | select('search', 'status=begin') | list }}" |
| 49 | + __journal_success: "{{ __journal_lines | select('search', 'status=success') | list }}" |
| 50 | + __begin_date: "{{ (__journal_begin[0] | regex_search('date=([^ ]+)', '\\1'))[0] }}" |
| 51 | + __success_date: "{{ (__journal_success[0] | regex_search('date=([^ ]+)', '\\1'))[0] }}" |
| 52 | + __file_content: "{{ __register_log_file.content | b64decode }}" |
| 53 | + block: |
| 54 | + - name: Print contents of logs |
| 55 | + debug: |
| 56 | + var: item |
| 57 | + loop: |
| 58 | + - "{{ __file_content }}" |
| 59 | + - "{{ __journal_lines }}" |
| 60 | + |
| 61 | + - name: Assert content is correct |
| 62 | + ansible.builtin.assert: |
| 63 | + that: |
| 64 | + - __journal_begin | length > 0 |
| 65 | + - __journal_success | length > 0 |
| 66 | + - __begin_date in __file_content |
| 67 | + - __success_date in __file_content |
| 68 | + |
41 | 69 | - name: Notify and run handlers |
42 | 70 | meta: flush_handlers |
43 | 71 |
|
|
0 commit comments