feat: add role fingerprints to syslog#125
Merged
richm merged 1 commit intolinux-system-roles:mainfrom Apr 24, 2026
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 custom Ansible module to emit role fingerprint messages to syslog and wires it into the keylime_server role, along with a journal-based integration test and necessary sanity ignore configuration. Sequence diagram for sr_fingerprint module logging to syslogsequenceDiagram
actor Operator
participant AnsiblePlay
participant AnsibleEngine
participant SrFingerprintModule
participant Syslog
Operator->>AnsiblePlay: Run keylime_server role
AnsiblePlay->>AnsibleEngine: Execute task sr_fingerprint
AnsibleEngine->>SrFingerprintModule: Invoke with sr_message
SrFingerprintModule->>SrFingerprintModule: _local_iso8601_no_microseconds()
alt check_mode is true
SrFingerprintModule-->>AnsibleEngine: exit_json(changed=false, message)
AnsibleEngine-->>AnsiblePlay: Task ok (no syslog write)
else check_mode is false
SrFingerprintModule->>Syslog: module.log(sr_message + timestamp)
SrFingerprintModule-->>AnsibleEngine: exit_json(changed=false)
AnsibleEngine-->>AnsiblePlay: Task ok (fingerprint logged)
end
AnsiblePlay-->>Operator: Role run summary with fingerprints in syslog
Class diagram for sr_fingerprint Ansible moduleclassDiagram
class SrFingerprintModule {
- sr_message str
+ run_module()
+ _local_iso8601_no_microseconds() str
+ main()
}
class AnsibleModule {
+ params dict
+ check_mode bool
+ log(message str) void
+ exit_json(changed bool, message str)
}
class datetime_module {
+ datetime
+ timezone
}
class time_module {
+ strftime(format str, t) str
+ localtime() struct_time
}
SrFingerprintModule --> AnsibleModule : uses
SrFingerprintModule --> datetime_module : uses
SrFingerprintModule --> time_module : fallback uses
Flow diagram for keylime_server role fingerprintsflowchart TD
A[Start keylime_server role] --> B[Task set_vars.yml]
B --> C[Record role begin fingerprint using sr_fingerprint]
C --> D[Other role tasks]
D -->|All tasks succeed| E[Record role success fingerprint using sr_fingerprint]
D -->|Any task fails| F[Role failure - success fingerprint not written]
E --> G[End role]
F --> G
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
journalctlshell task intests_default.ymlis fairly brittle (stringlygrep, repeatedjournalctlcalls, hard-coded role name); consider factoring this into a small script or using more targeted filters/regex to reduce false positives and make it easier to adapt if the fingerprint format changes. - The
sr_fingerprintmessages embedansible_facts['distribution']and['distribution_version'], which can contain spaces or unexpected characters; consider normalizing or quoting these values so log scanners can reliably parse the fingerprint. - The
_local_iso8601_no_microsecondshelper partly reimplements existing time handling; if possible, reuse Ansible’s existing time utilities or a single code path (e.g., always viaastimezone()with a clear fallback) to simplify the function and avoid subtle timezone/locale differences across environments.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `journalctl` shell task in `tests_default.yml` is fairly brittle (stringly `grep`, repeated `journalctl` calls, hard-coded role name); consider factoring this into a small script or using more targeted filters/regex to reduce false positives and make it easier to adapt if the fingerprint format changes.
- The `sr_fingerprint` messages embed `ansible_facts['distribution']` and `['distribution_version']`, which can contain spaces or unexpected characters; consider normalizing or quoting these values so log scanners can reliably parse the fingerprint.
- The `_local_iso8601_no_microseconds` helper partly reimplements existing time handling; if possible, reuse Ansible’s existing time utilities or a single code path (e.g., always via `astimezone()` with a clear fallback) to simplify the function and avoid subtle timezone/locale differences across environments.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 syslog fingerprinting for the keylime_server role and verify it via journal inspection in tests.
New Features:
Tests:
Chores: