feat: support this role in container builds#303
Merged
Conversation
Reviewer's GuideThis PR introduces a __timesync_is_booted flag to detect systemd runtime availability in container build environments and conditionally alters service discovery, state management, handler execution, and testing flow to support running the timesync role under buildah scenarios, alongside adding a metadata tag for container builds. Sequence diagram for conditional service management based on booted statesequenceDiagram
participant Ansible
participant System
participant Service
Ansible->>System: Run "systemctl is-system-running"
System-->>Ansible: Return status (e.g., 'offline', 'running')
Ansible->>Ansible: Set __timesync_is_booted flag
alt __timesync_is_booted is true
Ansible->>Service: Manage service state (start/stop/enable/disable)
else __timesync_is_booted is false
Ansible->>System: List unit files via "systemctl list-unit-files"
System-->>Ansible: Return service list
Ansible->>Ansible: Set timesync_services fact
Ansible->>Service: Only enable/disable, omit state changes
end
Class diagram for timesync role variables and service managementclassDiagram
class TimesyncRole {
+__timesync_is_booted: bool
+timesync_services: list
+Service Management (conditional on __timesync_is_booted)
}
class Service {
+name: string
+state: string ("started", "stopped", or omitted)
+enabled: bool
}
TimesyncRole "1" -- "*" Service : manages
TimesyncRole : determines __timesync_is_booted
TimesyncRole : sets timesync_services
Service : state set only if __timesync_is_booted
Service : enabled always set
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `handlers/main.yml:6` </location>
<code_context>
service:
name: chronyd
state: restarted
+ when: __timesync_is_booted | d(false)
- name: Restart ntpd
</code_context>
<issue_to_address>
Handler will be skipped if __timesync_is_booted is not set.
Confirm that skipping the handler when __timesync_is_booted is undefined is intentional, as this may affect environments where the variable is missing.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| service: | ||
| name: chronyd | ||
| state: restarted | ||
| when: __timesync_is_booted | d(false) |
There was a problem hiding this comment.
question: Handler will be skipped if __timesync_is_booted is not set.
Confirm that skipping the handler when __timesync_is_booted is undefined is intentional, as this may affect environments where the variable is missing.
Collaborator
Author
|
[citest] |
Collaborator
Author
|
[citest] |
Feature: Support running the timesync role during container builds. Reason: This is particularly useful for building bootc derivative OSes. Result: These flags enable running the bootc container scenarios in CI, which ensures that the role works in buildah build environment. This allows us to officially support this role for image mode builds. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
spetrosi
approved these changes
Sep 12, 2025
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: Support running the timesync role during container builds.
Reason: This is particularly useful for building bootc derivative OSes.
Result: These flags enable running the bootc container scenarios in CI,
which ensures that the role works in buildah build environment. This
allows us to officially support this role for image mode builds.
Signed-off-by: Rich Megginson rmeggins@redhat.com
Summary by Sourcery
Enable the timesync Ansible role to operate correctly in container build environments by detecting whether the system is booted and adjusting service discovery, start/stop operations, and CI tests accordingly.
New Features:
Enhancements:
Tests: