Skip to content

Commit 459448f

Browse files
spetrosiclaude
authored andcommitted
fix: Update sr_fingerprint task calls to use new structured parameters
The sr_fingerprint module was rewritten to accept structured parameters (status, role_name, role_path, etc.) instead of a free-form sr_message. Update the role tasks and tests to match the new module interface. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b0c98b7 commit 459448f

4 files changed

Lines changed: 51 additions & 13 deletions

File tree

tasks/main.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191

9292
- name: Record role success fingerprint
9393
sr_fingerprint:
94-
sr_message: >-
95-
success system_role:kdump ansible_version={{ ansible_version.full }}
96-
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
94+
status: success
95+
role_name: kdump
96+
role_path: "{{ role_path }}"
97+
ansible_play_hosts_all: "{{ ansible_play_hosts_all }}"
98+
distribution: "{{ ansible_facts['distribution'] }}"
99+
distribution_version: "{{ ansible_facts['distribution_version'] }}"
100+
write_log_file: "{{ __kdump_write_log_file }}"

tasks/set_vars.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88
- name: Record role begin fingerprint
99
sr_fingerprint:
10-
sr_message: >-
11-
begin system_role:kdump ansible_version={{ ansible_version.full }}
12-
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
10+
status: begin
11+
role_name: kdump
12+
role_path: "{{ role_path }}"
13+
ansible_play_hosts_all: "{{ ansible_play_hosts_all }}"
14+
distribution: "{{ ansible_facts['distribution'] }}"
15+
distribution_version: "{{ ansible_facts['distribution_version'] }}"
16+
write_log_file: "{{ __kdump_write_log_file }}"
1317

1418
- name: Determine if system is ostree and set flag
1519
when: not __kdump_is_ostree is defined

tests/tests_default_reboot.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,50 @@
2222
include_tasks: tasks/run_role_with_clear_facts.yml
2323
vars:
2424
__sr_public: true
25+
__kdump_write_log_file: true
2526

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
2828
ansible.builtin.shell:
2929
executable: /bin/bash
3030
cmd: >-
3131
set -eo pipefail;
3232
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
3836
changed_when: false
3937
when: __register_dev_log.stat.exists
4038

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+
4169
- name: Notify and run handlers
4270
meta: flush_handlers
4371

vars/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ __kdump_required_facts:
2626
__kdump_required_facts_subsets: "{{ ['!all', '!min'] +
2727
__kdump_required_facts }}"
2828

29+
__kdump_write_log_file: false
30+
2931
# BEGIN - DO NOT EDIT THIS BLOCK - rh distros variables
3032
# Ansible distribution identifiers that the role treats like RHEL
3133
__kdump_rh_distros:

0 commit comments

Comments
 (0)