feat: add role fingerprints to syslog#287
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>
Contributor
Reviewer's GuideAdds a new sr_fingerprint Ansible module and wires it into the kdump role to emit begin/success fingerprints to syslog, along with a test that validates the fingerprints appear in the system journal when the role runs successfully. Sequence diagram for kdump role syslog fingerprintssequenceDiagram
actor Operator
participant AnsibleController
participant KdumpRole
participant SrFingerprintModule
participant Syslog
Operator->>AnsibleController: run_playbook_with_kdump_role
AnsibleController->>KdumpRole: execute_tasks
KdumpRole->>SrFingerprintModule: task_Record_role_begin_fingerprint(sr_message="begin system_role:kdump ...")
SrFingerprintModule->>SrFingerprintModule: _local_iso8601_no_microseconds
SrFingerprintModule->>Syslog: module.log("begin system_role:kdump ... <timestamp>")
SrFingerprintModule-->>KdumpRole: exit_json(changed=False)
KdumpRole->>KdumpRole: perform_kdump_configuration
KdumpRole->>SrFingerprintModule: task_Record_role_success_fingerprint(sr_message="success system_role:kdump ...")
SrFingerprintModule->>SrFingerprintModule: _local_iso8601_no_microseconds
SrFingerprintModule->>Syslog: module.log("success system_role:kdump ... <timestamp>")
SrFingerprintModule-->>KdumpRole: exit_json(changed=False)
KdumpRole-->>AnsibleController: role_completed_successfully
AnsibleController-->>Operator: playbook_run_report
Updated class diagram for the sr_fingerprint Ansible moduleclassDiagram
class sr_fingerprint {
+run_module() void
+main() void
-_local_iso8601_no_microseconds() str
}
class AnsibleModule {
+params dict
+check_mode bool
+log(msg str) void
+exit_json(**kwargs) void
}
class datetime_module {
+datetime
+timezone
}
sr_fingerprint ..> AnsibleModule : uses
sr_fingerprint ..> datetime_module : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
sr_fingerprint._local_iso8601_no_microseconds, consider capturingdatetime.datetime.now()once and reusing it instead of calling it twice to avoid subtle inconsistencies around second boundaries and to simplify the logic. - The journal fingerprint test runs
journalctltwice and relies on shell pipelines withgrep; you could make this more robust and efficient by using a singlejournalctlinvocation with built-in filtering (e.g.-gorSYSLOG_IDENTIFIER/UNITconstraints) and reducing the shell logic to a single command.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `sr_fingerprint._local_iso8601_no_microseconds`, consider capturing `datetime.datetime.now()` once and reusing it instead of calling it twice to avoid subtle inconsistencies around second boundaries and to simplify the logic.
- The journal fingerprint test runs `journalctl` twice and relies on shell pipelines with `grep`; you could make this more robust and efficient by using a single `journalctl` invocation with built-in filtering (e.g. `-g` or `SYSLOG_IDENTIFIER`/`UNIT` constraints) and reducing the shell logic to a single command.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 a syslog fingerprinting mechanism to the kdump role and verify its presence via tests.
New Features:
Tests:
Chores: