Skip to content

Commit 8921bf1

Browse files
spetrosiclaude
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 c3ce8d6 commit 8921bf1

4 files changed

Lines changed: 52 additions & 12 deletions

File tree

tasks/main.yml

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

180180
- name: Record role success fingerprint
181181
sr_fingerprint:
182-
sr_message: >-
183-
success system_role:bootloader ansible_version={{ ansible_version.full }}
184-
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
182+
status: success
183+
role_name: bootloader
184+
role_path: "{{ role_path }}"
185+
ansible_play_hosts_all: "{{ ansible_play_hosts_all }}"
186+
distribution: "{{ ansible_facts['distribution'] }}"
187+
distribution_version: "{{ ansible_facts['distribution_version'] }}"
188+
write_log_file: "{{ __bootloader_write_log_file }}"

tasks/set_vars.yml

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

99
- name: Record role begin fingerprint
1010
sr_fingerprint:
11-
sr_message: >-
12-
begin system_role:bootloader ansible_version={{ ansible_version.full }}
13-
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
11+
status: begin
12+
role_name: bootloader
13+
role_path: "{{ role_path }}"
14+
ansible_play_hosts_all: "{{ ansible_play_hosts_all }}"
15+
distribution: "{{ ansible_facts['distribution'] }}"
16+
distribution_version: "{{ ansible_facts['distribution_version'] }}"
17+
write_log_file: "{{ __bootloader_write_log_file }}"
1418

1519
- name: Determine if system is ostree and set flag
1620
when: not __bootloader_is_ostree is defined

tests/tests_default.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,48 @@
1818

1919
- name: Run with default parameters
2020
include_tasks: tasks/run_role_with_clear_facts.yml
21+
vars:
22+
__bootloader_write_log_file: true
2123

2224
# look for the exact module invocation, not some other message that might contain the string
23-
- name: Check system journal contains role fingerprints
25+
- name: Get fingerprint entries from journal
2426
ansible.builtin.shell:
2527
executable: /bin/bash
2628
cmd: >-
2729
set -eo pipefail;
2830
journalctl --since "{{ __journal_start_time }}" --no-pager |
29-
grep -v " Invoked with" | grep "sr_fingerprint.*begin system_role:bootloader" ||
30-
{ echo ERROR: BEGIN fingerprint not found; exit 1; };
31-
journalctl --since "{{ __journal_start_time }}" --no-pager |
32-
grep -v " Invoked with" | grep "sr_fingerprint.*success system_role:bootloader" ||
33-
{ echo ERROR: SUCCESS fingerprint not found; exit 1; }
31+
grep -v " Invoked with" |
32+
grep "sr_fingerprint.*role_name=bootloader"
33+
register: __register_journal_fingerprints
3434
changed_when: false
3535
when: __register_dev_log.stat.exists
36+
37+
- name: Check that the log file was written
38+
ansible.builtin.slurp:
39+
path: /var/log/sysroles.jsonl
40+
register: __register_log_file
41+
42+
- name: Verify log file and journal fingerprints
43+
when: __register_dev_log.stat.exists
44+
vars:
45+
_journal_lines: "{{ __register_journal_fingerprints.stdout_lines }}"
46+
_journal_begin: "{{ _journal_lines | select('search', 'status=begin') | list }}"
47+
_journal_success: "{{ _journal_lines | select('search', 'status=success') | list }}"
48+
_begin_date: "{{ (_journal_begin[0] | regex_search('date=([^ ]+)', '\\1'))[0] }}"
49+
_success_date: "{{ (_journal_success[0] | regex_search('date=([^ ]+)', '\\1'))[0] }}"
50+
_file_content: "{{ __register_log_file.content | b64decode }}"
51+
block:
52+
- name: Print contents of logs
53+
debug:
54+
var: item
55+
loop:
56+
- "{{ _file_content }}"
57+
- "{{ _journal_lines }}"
58+
59+
- name: Assert content is correct
60+
ansible.builtin.assert:
61+
that:
62+
- _journal_begin | length > 0
63+
- _journal_success | length > 0
64+
- _begin_date in _file_content
65+
- _success_date in _file_content

vars/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ __bootloader_uefi_conf_dir: >-
2828
{%- endif -%}
2929
__bootloader_bios_conf_dir: /boot/grub2/
3030

31+
__bootloader_write_log_file: false
32+
3133
# BEGIN - DO NOT EDIT THIS BLOCK - rh distros variables
3234
# Ansible distribution identifiers that the role treats like RHEL
3335
__bootloader_rh_distros:

0 commit comments

Comments
 (0)