feat: add role fingerprints to syslog#345
Merged
Merged
Conversation
Reviewer's GuideAdds a new sr_fingerprint Ansible module and wires it into the timesync role to emit begin/success fingerprints to syslog, along with a test that validates fingerprints were written using journalctl, plus sanity-ignore updates for the new module. Sequence diagram for sr_fingerprint logging during timesync role executionsequenceDiagram
actor Admin
participant AnsibleController
participant TimesyncRole_SetVars
participant TimesyncRole_Main
participant SrFingerprintModule
participant Syslog
Admin->>AnsibleController: Run playbook with timesync role
AnsibleController->>TimesyncRole_SetVars: Execute set_vars tasks
TimesyncRole_SetVars->>SrFingerprintModule: sr_fingerprint(sr_message=begin system_role:timesync ...)
activate SrFingerprintModule
SrFingerprintModule->>SrFingerprintModule: _local_iso8601_no_microseconds()
SrFingerprintModule->>Syslog: module.log(begin ... <timestamp>)
SrFingerprintModule-->>TimesyncRole_SetVars: exit_json(changed=false)
deactivate SrFingerprintModule
AnsibleController->>TimesyncRole_Main: Execute main tasks
TimesyncRole_Main->>TimesyncRole_Main: Configure timesync
TimesyncRole_Main->>SrFingerprintModule: sr_fingerprint(sr_message=success system_role:timesync ...)
activate SrFingerprintModule
SrFingerprintModule->>SrFingerprintModule: _local_iso8601_no_microseconds()
SrFingerprintModule->>Syslog: module.log(success ... <timestamp>)
SrFingerprintModule-->>TimesyncRole_Main: exit_json(changed=false)
deactivate SrFingerprintModule
TimesyncRole_Main-->>AnsibleController: Role completed
AnsibleController-->>Admin: Report role success
Class diagram for the sr_fingerprint Ansible moduleclassDiagram
class SrFingerprintModule {
<<module>>
+run_module()
+main()
-_local_iso8601_no_microseconds() str
}
class AnsibleModule {
+params dict
+check_mode bool
+log(message)
+exit_json(changed, message)
}
SrFingerprintModule ..> AnsibleModule : uses
Flow diagram for begin and success fingerprints in the timesync roleflowchart TD
A[Start timesync role] --> B[Run set_vars.yml]
B --> C[Call sr_fingerprint with begin system_role:timesync ...]
C --> D[Write begin fingerprint to syslog]
D --> E[Run main.yml tasks]
E --> F[Configure timesync services]
F --> G[Call sr_fingerprint with success system_role:timesync ...]
G --> H[Write success fingerprint to syslog]
H --> I[End timesync role]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Collaborator
Author
|
[citest] |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- sr_fingerprint.py has a duplicated shebang (
#!/usr/bin/python) at the top; you can drop the second one to avoid confusion. - The journalctl fingerprint check in tests_default.yml is a long bash one-liner; consider splitting it into separate tasks or using
register/failed_whento make the logic (BEGIN vs SUCCESS checks, grep filters) easier to read and maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- sr_fingerprint.py has a duplicated shebang (`#!/usr/bin/python`) at the top; you can drop the second one to avoid confusion.
- The journalctl fingerprint check in tests_default.yml is a long bash one-liner; consider splitting it into separate tasks or using `register`/`failed_when` to make the logic (BEGIN vs SUCCESS checks, grep filters) easier to read and maintain.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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>
Collaborator
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 timesync role and verify fingerprints via journal inspection in tests.
New Features:
Tests: