feat: add role fingerprints to syslog - #250
Merged
Merged
Conversation
Reviewer's GuideAdds a custom sr_fingerprint Ansible module to write role fingerprint messages to syslog, wires it into the VPN role at begin/success entry points, and extends the default test to validate that the fingerprints are emitted via journalctl when syslog is available, along with the necessary sanity ignore and library wiring for the role tests. Sequence diagram for VPN role fingerprints written to syslogsequenceDiagram
actor User
participant AnsibleController
participant VPNRole
participant sr_fingerprint
participant Syslog
User->>AnsibleController: Run_playbook_with_vpn_role
AnsibleController->>VPNRole: Execute_tasks
rect rgb(230,230,255)
VPNRole->>sr_fingerprint: Record_role_begin_fingerprint(sr_message)
activate sr_fingerprint
sr_fingerprint->>sr_fingerprint: _local_iso8601_no_microseconds()
sr_fingerprint->>Syslog: module.log("begin system_role:vpn ... <timestamp>")
sr_fingerprint-->>VPNRole: exit_json(changed=False)
deactivate sr_fingerprint
end
VPNRole->>VPNRole: Configure_VPN_resources
rect rgb(230,255,230)
VPNRole->>sr_fingerprint: Record_role_success_fingerprint(sr_message)
activate sr_fingerprint
sr_fingerprint->>sr_fingerprint: _local_iso8601_no_microseconds()
sr_fingerprint->>Syslog: module.log("success system_role:vpn ... <timestamp>")
sr_fingerprint-->>VPNRole: exit_json(changed=False)
deactivate sr_fingerprint
end
VPNRole-->>AnsibleController: Role_completed
AnsibleController-->>User: Report_success
Class diagram for the new sr_fingerprint Ansible moduleclassDiagram
class sr_fingerprint_module {
+run_module()
+main()
-_local_iso8601_no_microseconds()
}
class AnsibleModule {
+params
+check_mode
+log(msg)
+exit_json(changed, message)
}
sr_fingerprint_module ..> AnsibleModule : uses
class FingerprintLoggingFlow {
+sr_message : str
+log_message : str
+compose_log_message(sr_message)
+log_with_timestamp()
}
sr_fingerprint_module ..> FingerprintLoggingFlow : internal_logic
class VPNRoleTasks {
+Record_role_begin_fingerprint
+Record_role_success_fingerprint
}
VPNRoleTasks ..> sr_fingerprint_module : invokes
class TimestampSource {
+_local_iso8601_no_microseconds()
}
sr_fingerprint_module ..> TimestampSource : obtains_timestamp
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_messageformat string for the begin/success fingerprints is duplicated inset_vars.ymlandtasks/main.yml; consider centralizing the construction of this message (e.g. via a variable or included task) so changes to the format only need to be made in one place. - The test that checks for fingerprints invokes
journalctltwice with the same--sincefilter; you could simplify and make this slightly less brittle by callingjournalctlonce and grepping for both begin and success fingerprints in that single output.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `sr_message` format string for the begin/success fingerprints is duplicated in `set_vars.yml` and `tasks/main.yml`; consider centralizing the construction of this message (e.g. via a variable or included task) so changes to the format only need to be made in one place.
- The test that checks for fingerprints invokes `journalctl` twice with the same `--since` filter; you could simplify and make this slightly less brittle by calling `journalctl` once and grepping for both begin and success fingerprints in that single output.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #250 +/- ##
======================================
Coverage ? 0.00%
======================================
Files ? 1
Lines ? 33
Branches ? 0
======================================
Hits ? 0
Misses ? 33
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
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 syslog fingerprinting for the VPN system role and verify its presence in the system journal during tests.
New Features:
Tests:
Chores: