feat: add role fingerprints to syslog#236
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 and wires it into the ssh role to emit begin/success fingerprints to syslog, plus a journal-based test and supporting sanity/compatibility files. Sequence diagram for sr_fingerprint role begin/success loggingsequenceDiagram
actor DevOpsEngineer
participant AnsibleController
participant ManagedHost
participant ssh_role
participant sr_fingerprint_module
participant SyslogDaemon
participant Journal
DevOpsEngineer->>AnsibleController: run ansible_playbook with ssh_role
AnsibleController->>ManagedHost: execute ssh_role tasks
rect rgb(235,235,255)
ssh_role->>sr_fingerprint_module: begin sr_message
sr_fingerprint_module->>sr_fingerprint_module: _local_iso8601_no_microseconds()
alt check_mode
sr_fingerprint_module-->>ssh_role: exit_json changed=false
else normal_mode
sr_fingerprint_module->>SyslogDaemon: module.log(begin message timestamp)
SyslogDaemon->>Journal: write begin entry
SyslogDaemon-->>sr_fingerprint_module: ok
sr_fingerprint_module-->>ssh_role: exit_json changed=false
end
end
ssh_role->>ssh_role: perform ssh configuration tasks
rect rgb(235,255,235)
ssh_role->>sr_fingerprint_module: success sr_message
sr_fingerprint_module->>sr_fingerprint_module: _local_iso8601_no_microseconds()
alt check_mode
sr_fingerprint_module-->>ssh_role: exit_json changed=false
else normal_mode
sr_fingerprint_module->>SyslogDaemon: module.log(success message timestamp)
SyslogDaemon->>Journal: write success entry
SyslogDaemon-->>sr_fingerprint_module: ok
sr_fingerprint_module-->>ssh_role: exit_json changed=false
end
end
ManagedHost-->>AnsibleController: task results
AnsibleController-->>DevOpsEngineer: play recap and logs
Class diagram for sr_fingerprint Ansible module structureclassDiagram
class sr_fingerprint {
+run_module()
+_local_iso8601_no_microseconds()
+main()
}
class AnsibleModule {
+AnsibleModule(argument_spec, supports_check_mode)
+log(message)
+exit_json(changed, message)
}
class datetime {
+datetime
+timezone
+now()
}
class time {
+strftime(format, struct_time)
+localtime()
}
sr_fingerprint ..> AnsibleModule : uses
sr_fingerprint ..> datetime : uses
sr_fingerprint ..> time : uses
sr_fingerprint : sr_message str
sr_fingerprint : log_message str
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
Author
|
[citest] |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
Check system journal contains role fingerprintstask relies on a longshellpipeline withgrep; consider switching to thecommandmodule plusregisterandassertto avoid shell parsing issues and make the checks easier to maintain. - The
_local_iso8601_no_microsecondsfunction reimplements timestamp formatting logic; if there is an existing utility in your collection or standard libs you can reuse, it would simplify the module and reduce the chance of subtle datetime bugs. - The
.sanity-ansible-ignore-*files are added but empty in the diff; if they are meant to suppress specific sanity rules, consider adding a short comment or the explicit rule names so future maintainers understand why they exist.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `Check system journal contains role fingerprints` task relies on a long `shell` pipeline with `grep`; consider switching to the `command` module plus `register` and `assert` to avoid shell parsing issues and make the checks easier to maintain.
- The `_local_iso8601_no_microseconds` function reimplements timestamp formatting logic; if there is an existing utility in your collection or standard libs you can reuse, it would simplify the module and reduce the chance of subtle datetime bugs.
- The `.sanity-ansible-ignore-*` files are added but empty in the diff; if they are meant to suppress specific sanity rules, consider adding a short comment or the explicit rule names so future maintainers understand why they exist.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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 reusable fingerprinting mechanism that logs ssh system role lifecycle events to syslog and verify its presence via tests.
New Features:
Tests:
Chores: