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>
This commit is contained in:
Sergei Petrosian
2026-08-06 16:11:09 -06:00
committed by Richard Megginson
co-authored by Claude Opus 4.6
parent d9ba105ef3
commit 83471be571
4 changed files with 52 additions and 12 deletions
+7 -3
View File
@@ -155,6 +155,10 @@
- name: Record role success fingerprint
sr_fingerprint:
sr_message: >-
success system_role:aide ansible_version={{ ansible_version.full }}
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
status: success
role_name: aide
role_path: "{{ role_path }}"
ansible_play_hosts_all: "{{ ansible_play_hosts_all }}"
distribution: "{{ ansible_facts['distribution'] }}"
distribution_version: "{{ ansible_facts['distribution_version'] }}"
write_log_file: "{{ __aide_write_log_file }}"
+7 -3
View File
@@ -7,9 +7,13 @@
- name: Record role begin fingerprint
sr_fingerprint:
sr_message: >-
begin system_role:aide ansible_version={{ ansible_version.full }}
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
status: begin
role_name: aide
role_path: "{{ role_path }}"
ansible_play_hosts_all: "{{ ansible_play_hosts_all }}"
distribution: "{{ ansible_facts['distribution'] }}"
distribution_version: "{{ ansible_facts['distribution_version'] }}"
write_log_file: "{{ __aide_write_log_file }}"
- name: Determine if system is ostree and set flag
when: not __aide_is_ostree is defined
+36 -6
View File
@@ -15,22 +15,52 @@
- name: Run the role
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__aide_write_log_file: true
# look for the exact module invocation, not some other message that might contain the string
- name: Check system journal contains role fingerprints
- name: Get fingerprint entries from journal
ansible.builtin.shell:
executable: /bin/bash
cmd: >-
set -eo pipefail;
journalctl --since "{{ __journal_start_time }}" --no-pager |
grep -v " Invoked with" | grep "sr_fingerprint.*begin system_role:aide" ||
{ echo ERROR: BEGIN fingerprint not found; exit 1; };
journalctl --since "{{ __journal_start_time }}" --no-pager |
grep -v " Invoked with" | grep "sr_fingerprint.*success system_role:aide" ||
{ echo ERROR: SUCCESS fingerprint not found; exit 1; }
grep -v " Invoked with" |
grep "sr_fingerprint.*role_name=aide"
register: __register_journal_fingerprints
changed_when: false
when: __register_dev_log.stat.exists
- name: Check that the log file was written
ansible.builtin.slurp:
path: /var/log/sysroles.jsonl
register: __register_log_file
- name: Verify log file and journal fingerprints
when: __register_dev_log.stat.exists
vars:
__journal_lines: "{{ __register_journal_fingerprints.stdout_lines }}"
__journal_begin: "{{ __journal_lines | select('search', 'status=begin') | list }}"
__journal_success: "{{ __journal_lines | select('search', 'status=success') | list }}"
__begin_date: "{{ (__journal_begin[0] | regex_search('date=([^ ]+)', '\\1'))[0] }}"
__success_date: "{{ (__journal_success[0] | regex_search('date=([^ ]+)', '\\1'))[0] }}"
__file_content: "{{ __register_log_file.content | b64decode }}"
block:
- name: Print contents of logs
debug:
var: item
loop:
- "{{ __file_content }}"
- "{{ __journal_lines }}"
- name: Assert content is correct
ansible.builtin.assert:
that:
- __journal_begin | length > 0
- __journal_success | length > 0
- __begin_date in __file_content
- __success_date in __file_content
- name: Check if the file exists
ansible.builtin.stat:
path: /etc/aide.conf
+2
View File
@@ -23,6 +23,8 @@ __aide_required_facts:
__aide_required_facts_subsets: "{{ ['!all', '!min'] +
__aide_required_facts }}"
__aide_write_log_file: false
# BEGIN - DO NOT EDIT THIS BLOCK - rh distros variables
# Ansible distribution identifiers that the role treats like RHEL
__aide_rh_distros: