feat: add role fingerprints to syslog

Feature: Add a fingerprint string to the system log to indicate when the role began
successfully, and when the role finished successfully.  The fingerprint string indicates
the role name, a timestamp, and the platform.

Reason: Users can see when the role was used and if it was used successfully.  This
information from the system log can be collected by log scanners and aggregators
for further analysis.

Result: The role logs fingerprints to the system log.

This also adds a test to check if the fingerprints were written upon a successful
role invocation.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
This commit is contained in:
Rich Megginson
2026-04-22 10:52:25 -06:00
committed by Richard Megginson
parent 19b462a7f8
commit 659d89dd69
13 changed files with 126 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
../../../library
+17
View File
@@ -3,8 +3,25 @@
- name: Ensure that the role runs with default parameters
hosts: all
tasks:
- name: Set the start time for the journal search
set_fact:
__journal_start_time: "{{ ansible_facts['date_time']['date'] ~ ' ' ~ ansible_facts['date_time']['time'] }}"
- name: Run the role
include_tasks: tasks/run_role_with_clear_facts.yml
# look for the exact module invocation, not some other message that might contain the string
- name: Check system journal contains role fingerprints
shell: >-
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; }
changed_when: false
- name: Check if the file exists
ansible.builtin.stat:
path: /etc/aide.conf