feat: add role fingerprints to syslog#216
Merged
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 tlog system role to emit begin/success fingerprints to syslog, along with a test that validates the fingerprints via journalctl and related sanity/compatibility wiring. Sequence diagram for tlog role begin/success fingerprints via sr_fingerprintsequenceDiagram
actor Admin
participant AnsibleController
participant ManagedHost
participant Role_tlog
participant Module_sr_fingerprint
participant Syslog
Admin->>AnsibleController: Run playbook using tlog role
AnsibleController->>ManagedHost: Execute tlog role tasks
rect rgb(235, 245, 255)
Role_tlog->>Module_sr_fingerprint: Record role begin fingerprint
Module_sr_fingerprint->>Module_sr_fingerprint: _local_iso8601_no_microseconds()
Module_sr_fingerprint->>Syslog: module.log("begin system_role:tlog ... <timestamp>")
Module_sr_fingerprint-->>Role_tlog: changed=False
end
Role_tlog->>ManagedHost: Execute remaining tlog configuration tasks
rect rgb(235, 245, 255)
Role_tlog->>Module_sr_fingerprint: Record role success fingerprint
Module_sr_fingerprint->>Module_sr_fingerprint: _local_iso8601_no_microseconds()
Module_sr_fingerprint->>Syslog: module.log("success system_role:tlog ... <timestamp>")
Module_sr_fingerprint-->>Role_tlog: changed=False
end
Role_tlog-->>AnsibleController: Role completed
AnsibleController-->>Admin: Report success, fingerprints available in syslog
Class diagram for sr_fingerprint Ansible module structureclassDiagram
class sr_fingerprint {
+run_module() void
+main() void
-_local_iso8601_no_microseconds() str
}
class AnsibleModule {
+params dict
+check_mode bool
+log(message str) void
+exit_json(**kwargs) void
}
class datetime {
<<library>>
}
sr_fingerprint ..> AnsibleModule : uses
sr_fingerprint ..> datetime : uses
class run_module_flow {
+sr_message str
+log_message str
}
sr_fingerprint .. run_module_flow : constructs log_message
run_module_flow : "log_message = sr_message + ' ' + _local_iso8601_no_microseconds()"
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 test that greps for
sr_fingerprint.*begin system_role:tlogrelies on the exact formatting ofmodule.logoutput and assumes the module name appears in the log line; it would be more robust to either include a distinctive prefix insr_messageitself or adjust the grep to match only content you fully control. - The journal check currently runs
journalctltwice with similar filters; consider invokingjournalctlonce and running both checks over that output to reduce overhead and avoid any chance of messages appearing between the two calls.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The test that greps for `sr_fingerprint.*begin system_role:tlog` relies on the exact formatting of `module.log` output and assumes the module name appears in the log line; it would be more robust to either include a distinctive prefix in `sr_message` itself or adjust the grep to match only content you fully control.
- The journal check currently runs `journalctl` twice with similar filters; consider invoking `journalctl` once and running both checks over that output to reduce overhead and avoid any chance of messages appearing between the two calls.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 custom Ansible module and role hooks to emit syslog fingerprints when the tlog system role starts and completes, and verify their presence via tests.
New Features:
Tests:
Chores: