feat: add role fingerprints to syslog#329
Merged
Merged
Conversation
Reviewer's GuideImplements a new Ansible module sr_fingerprint that logs role fingerprint messages to syslog and wires it into the certificate role to emit begin/success markers, with tests verifying the fingerprints appear in the system journal. Sequence diagram for sr_fingerprint syslog logging during role executionsequenceDiagram
actor User
participant AnsibleController
participant CertificateRole
participant SrFingerprintModule
participant Syslog
User->>AnsibleController: Run playbook using certificate role
AnsibleController->>CertificateRole: Execute tasks
CertificateRole->>SrFingerprintModule: sr_fingerprint sr_message="begin system_role:certificate ..."
SrFingerprintModule->>SrFingerprintModule: _local_iso8601_no_microseconds()
alt check_mode
SrFingerprintModule-->>AnsibleController: exit_json(changed=False, message="Check mode: message not logged ...")
else normal_mode
SrFingerprintModule->>Syslog: module.log("begin ... <timestamp>")
SrFingerprintModule-->>AnsibleController: exit_json(changed=False)
end
CertificateRole->>CertificateRole: Perform certificate tasks
CertificateRole->>SrFingerprintModule: sr_fingerprint sr_message="success system_role:certificate ..."
SrFingerprintModule->>SrFingerprintModule: _local_iso8601_no_microseconds()
alt check_mode
SrFingerprintModule-->>AnsibleController: exit_json(changed=False, message="Check mode: message not logged ...")
else normal_mode
SrFingerprintModule->>Syslog: module.log("success ... <timestamp>")
SrFingerprintModule-->>AnsibleController: exit_json(changed=False)
end
Class diagram for the new sr_fingerprint Ansible moduleclassDiagram
class SrFingerprintModule {
+str sr_message
+run_module()
+_local_iso8601_no_microseconds() str
+main()
}
class AnsibleModule {
+dict params
+log(str message)
+exit_json(bool changed, str message)
}
SrFingerprintModule --> AnsibleModule : uses
class DateTimeLibrary {
+now()
+astimezone()
+isoformat()
}
SrFingerprintModule --> DateTimeLibrary : uses for timestamps
Flow diagram for certificate role with begin/success fingerprintsflowchart TD
A["Start certificate role"] --> B["tasks/set_vars.yml: Gather required facts"]
B --> C["tasks/set_vars.yml: Record role begin fingerprint using sr_fingerprint"]
C --> D["tasks/main.yml: Execute main certificate tasks"]
D --> E["tasks/main.yml: Record role success fingerprint using sr_fingerprint"]
E --> F["End certificate role"]
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_fingerprintmodule always logs in local time with a derived timezone offset; if you need consistent cross-host correlation it may be worth including the host name explicitly insr_messageor logging a UTC timestamp alongside the local one. - The journal check in
tests_default.ymlcurrently uses a fairly brittle shell pipeline; consider callingjournalctlvia thecommandmodule, registering its output, and asserting on the presence of the begin/success fingerprints in YAML (to avoid issues with multiple matches, quoting, and pipefail handling).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `sr_fingerprint` module always logs in local time with a derived timezone offset; if you need consistent cross-host correlation it may be worth including the host name explicitly in `sr_message` or logging a UTC timestamp alongside the local one.
- The journal check in `tests_default.yml` currently uses a fairly brittle shell pipeline; consider calling `journalctl` via the `command` module, registering its output, and asserting on the presence of the begin/success fingerprints in YAML (to avoid issues with multiple matches, quoting, and pipefail handling).Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Collaborator
Author
|
[citest] |
12bc0c2 to
4379ef9
Compare
Collaborator
Author
|
[citest] |
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 a role-internal module to write fingerprint messages to syslog and integrate it into the certificate system role lifecycle.
New Features:
Tests: