feat: add role fingerprints to syslog#273
Merged
richm merged 1 commit intolinux-system-roles:mainfrom Apr 27, 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 emit role start/success markers to syslog, wires it into the rhc system role at begin/success points, and introduces an end-to-end test that validates the fingerprints via journalctl when /dev/log is available, along with sanity-ignore metadata for the new module across Ansible versions. Sequence diagram for sr_fingerprint role begin/success loggingsequenceDiagram
actor Admin
participant AnsibleController
participant ManagedHost
participant sr_fingerprint_module
participant Syslog
Admin->>AnsibleController: Run rhc_system_role
AnsibleController->>ManagedHost: Execute tasks/set_vars.yml
ManagedHost->>sr_fingerprint_module: Record role begin fingerprint
sr_fingerprint_module->>sr_fingerprint_module: _local_iso8601_no_microseconds
alt check_mode_enabled
sr_fingerprint_module-->>ManagedHost: exit_json(changed=false, message)
else normal_mode
sr_fingerprint_module->>Syslog: module.log("begin system_role:rhc ... <timestamp>")
sr_fingerprint_module-->>ManagedHost: exit_json(changed=false)
end
AnsibleController->>ManagedHost: Execute tasks/main.yml
ManagedHost->>sr_fingerprint_module: Record role success fingerprint
sr_fingerprint_module->>sr_fingerprint_module: _local_iso8601_no_microseconds
alt check_mode_enabled
sr_fingerprint_module-->>ManagedHost: exit_json(changed=false, message)
else normal_mode
sr_fingerprint_module->>Syslog: module.log("success system_role:rhc ... <timestamp>")
sr_fingerprint_module-->>ManagedHost: exit_json(changed=false)
end
Class diagram for sr_fingerprint Ansible moduleclassDiagram
class sr_fingerprint_module {
+run_module()
+main()
-_local_iso8601_no_microseconds()
}
class AnsibleModule {
+params dict
+check_mode bool
+log(msg str)
+exit_json(**kwargs)
}
sr_fingerprint_module ..> AnsibleModule : uses
class _local_iso8601_no_microseconds_function {
+_local_iso8601_no_microseconds() str
}
sr_fingerprint_module --> _local_iso8601_no_microseconds_function : calls
class RoleTasks_set_vars_yml {
+Record_role_begin_fingerprint()
}
class RoleTasks_main_yml {
+Record_role_success_fingerprint()
}
RoleTasks_set_vars_yml --> sr_fingerprint_module : invokes
RoleTasks_main_yml --> sr_fingerprint_module : invokes
Flow diagram for rhc role execution with fingerprintsflowchart TD
A[Start rhc_role] --> B[Load set_vars.yml]
B --> C[Gather required facts]
C --> D[Record role begin fingerprint via sr_fingerprint]
D --> E[Determine if system is ostree and set flag]
E --> F[Other role tasks]
F --> G[Conditional tasks in main.yml]
G --> H[Record role success fingerprint via sr_fingerprint]
H --> I[End rhc_role]
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
sr_messagestrings for the begin/success fingerprints are duplicated inset_vars.ymlandmain.yml; consider factoring the common parts (role name, Ansible version, distro/version) into a shared variable to avoid divergence over time. - The journal-check shell task in
tests_repositories.ymlis fairly brittle (multiplejournalctlinvocations, plaingrep, filtering outInvoked withlines); consider tightening it with a singlejournalctlcall and a more specific regex/anchored pattern so it is less sensitive to log format or unrelated messages.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `sr_message` strings for the begin/success fingerprints are duplicated in `set_vars.yml` and `main.yml`; consider factoring the common parts (role name, Ansible version, distro/version) into a shared variable to avoid divergence over time.
- The journal-check shell task in `tests_repositories.yml` is fairly brittle (multiple `journalctl` invocations, plain `grep`, filtering out `Invoked with` lines); consider tightening it with a single `journalctl` call and a more specific regex/anchored pattern so it is less sensitive to log format or unrelated messages.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
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 role fingerprint logging to syslog for the rhc system role and verify it via system journal tests.
New Features:
Tests:
Chores: