fix: use ansible_facts timesync_ntp_provider_current#331
Merged
richm merged 1 commit intolinux-system-roles:mainfrom Feb 12, 2026
Merged
Conversation
Cause: When using ANSIBLE_INJECT_FACT_VARS=false, the fact timesync_ntp_provider_current is not made into a top level variable. Consequence: The current timesync provider cannot be determined. Fix: Use the value from ansible_facts. Result: The timesync provider is correctly determined. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the timesync role to read the current NTP provider from ansible_facts instead of a top-level variable, ensuring correct behavior when ANSIBLE_INJECT_FACT_VARS is disabled, and registers the provider discovery task result for later use if needed. Sequence diagram for NTP provider selection in timesync rolesequenceDiagram
actor AnsibleUser
participant AnsibleController
participant ManagedHost
participant AnsibleFacts
AnsibleUser->>AnsibleController: Run timesync role
AnsibleController->>ManagedHost: Gather facts
ManagedHost-->>AnsibleController: ansible_facts including timesync_ntp_provider_current
AnsibleController->>ManagedHost: Task ensure timesync_ntp_provider is empty
ManagedHost-->>AnsibleController: timesync_provider_result
AnsibleController->>ManagedHost: Task Select NTP provider
Note over AnsibleController,ManagedHost: When timesync_mode != 2 and timesync_ntp_provider is empty
AnsibleController->>AnsibleFacts: Read ansible_facts timesync_ntp_provider_current
AnsibleFacts-->>AnsibleController: timesync_ntp_provider_current
AnsibleController->>ManagedHost: set_fact timesync_ntp_provider from ansible_facts or default
AnsibleController-->>AnsibleUser: timesync_ntp_provider correctly determined
Flow diagram for timesync_ntp_provider determination logicflowchart TD
A[timesync_mode != 2?] -->|no| B[Skip provider detection]
A -->|yes| C[timesync_ntp_provider length == 0?]
C -->|no| B
C -->|yes| D[Run provider discovery task<br/>register timesync_provider_result]
D --> E[Select NTP provider<br/>set_fact timesync_ntp_provider = ansible_facts[timesync_ntp_provider_current] or timesync_ntp_provider_os_default]
E --> F[Use timesync_ntp_provider for further tasks]
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:
- Accessing
ansible_facts['timesync_ntp_provider_current']directly will fail if the key is absent; consider usingansible_facts.timesync_ntp_provider_current | default(...)oransible_facts.get('timesync_ntp_provider_current') | default(...)so thedefaultfilter can actually guard against missing data. - The newly added
register: timesync_provider_resultis not used anywhere in this diff; if it’s not needed, remove it to avoid confusion about its purpose.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Accessing `ansible_facts['timesync_ntp_provider_current']` directly will fail if the key is absent; consider using `ansible_facts.timesync_ntp_provider_current | default(...)` or `ansible_facts.get('timesync_ntp_provider_current') | default(...)` so the `default` filter can actually guard against missing data.
- The newly added `register: timesync_provider_result` is not used anywhere in this diff; if it’s not needed, remove it to avoid confusion about its purpose.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Cause: When using ANSIBLE_INJECT_FACT_VARS=false, the fact timesync_ntp_provider_current
is not made into a top level variable.
Consequence: The current timesync provider cannot be determined.
Fix: Use the value from ansible_facts.
Result: The timesync provider is correctly determined.
Signed-off-by: Rich Megginson rmeggins@redhat.com
Summary by Sourcery
Bug Fixes: