feat: add role fingerprints to syslog#308
Merged
richm merged 1 commit intolinux-system-roles:mainfrom Apr 24, 2026
Merged
Conversation
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>
Reviewer's GuideAdds a new sr_fingerprint Ansible module to write timestamped role begin/success markers to syslog and wires it into the kernel_settings role, along with a journal-based test and corresponding sanity ignore updates. Sequence diagram for logging role begin/success fingerprints to syslogsequenceDiagram
actor Operator
participant AnsibleController
participant kernel_settings_role
participant sr_fingerprint_module
participant Syslog
Operator->>AnsibleController: Run play using kernel_settings role
AnsibleController->>kernel_settings_role: Execute tasks/set_vars.yml
kernel_settings_role->>sr_fingerprint_module: sr_fingerprint(sr_message="begin system_role:kernel_settings ...")
activate sr_fingerprint_module
sr_fingerprint_module->>sr_fingerprint_module: _local_iso8601_no_microseconds()
sr_fingerprint_module->>Syslog: module.log("begin ... <timestamp>")
sr_fingerprint_module-->>kernel_settings_role: exit_json(changed=False)
deactivate sr_fingerprint_module
kernel_settings_role->>kernel_settings_role: Apply kernel settings tasks
kernel_settings_role->>sr_fingerprint_module: sr_fingerprint(sr_message="success system_role:kernel_settings ...")
activate sr_fingerprint_module
sr_fingerprint_module->>sr_fingerprint_module: _local_iso8601_no_microseconds()
sr_fingerprint_module->>Syslog: module.log("success ... <timestamp>")
sr_fingerprint_module-->>kernel_settings_role: exit_json(changed=False)
deactivate sr_fingerprint_module
kernel_settings_role-->>AnsibleController: Role completed
AnsibleController-->>Operator: Report successful role run
Flow diagram for kernel_settings role with begin/success fingerprintsflowchart TD
A[Start kernel_settings role] --> B[Run tasks/set_vars.yml]
B --> C[Call sr_fingerprint module with sr_message begin system_role:kernel_settings ...]
C --> D[Syslog contains begin fingerprint with timestamp]
D --> E[Execute kernel settings configuration tasks]
E --> F[Run tasks/main.yml tail tasks]
F --> G[Call sr_fingerprint module with sr_message success system_role:kernel_settings ...]
G --> H[Syslog contains success fingerprint with timestamp]
H --> I[Role completes without reporting changed status from fingerprints]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The fingerprint message format (role name, ansible version, distro/version) is duplicated between the begin and success tasks; consider centralizing this into a variable or template so that future changes only need to be made in one place.
- In the sr_fingerprint module, it may be helpful to include the final log message in the exit_json payload (e.g. under a
logged_messagekey) to make it easier to debug or verify behavior without having to inspect syslog. - The journalctl-based fingerprint test assumes journalctl is present and working; if this role is expected to run on systems without journald, consider detecting journalctl availability and conditionally skipping the fingerprint verification rather than failing the test.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The fingerprint message format (role name, ansible version, distro/version) is duplicated between the begin and success tasks; consider centralizing this into a variable or template so that future changes only need to be made in one place.
- In the sr_fingerprint module, it may be helpful to include the final log message in the exit_json payload (e.g. under a `logged_message` key) to make it easier to debug or verify behavior without having to inspect syslog.
- The journalctl-based fingerprint test assumes journalctl is present and working; if this role is expected to run on systems without journald, consider detecting journalctl availability and conditionally skipping the fingerprint verification rather than failing the test.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Collaborator
Author
|
[citest] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Summary by Sourcery
Add a role-internal fingerprinting mechanism that logs begin/success markers to syslog and verify its presence via tests.
New Features:
Tests: