Skip to content

fix: the time baseline accepts any NTP daemon, not only timesyncd - #5

Merged
romamo merged 1 commit into
mainfrom
fix/time-role-any-ntp-daemon
Sep 30, 2026
Merged

romamo merged 1 commit into
mainfrom
fix/time-role-any-ntp-daemon

Conversation

@romamo

@romamo romamo commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Problem

timedatectl set-ntp only switches systemd-timesyncd. On a host whose clock is kept by ntp, ntpsec, or chrony, timedatectl reports CanNTP=no NTP=no NTPSynchronized=yes, and the cloudfall_time role treated that as drift:

  • check mode reported "Would enable network time synchronization"
  • a deploy failed with Failed to set ntp: NTP not supported

Hit on atlas-fleet: task time:deploy TIME_LIMIT=h2,h3,h4,h5 failed on h2. Nothing was changed, since the play runs one host at a time.

Host OS Keeps time Synchronized
h1 Debian trixie systemd-timesyncd yes
h2, h3, h5 Debian 12 ntpsec yes
h4 Debian 11 ntp yes

Fix

  • Read CanNTP before and after
  • Report and switch NTP only where systemd-timesyncd is installed (CanNTP=yes); the baseline assertion requires NTP=yes only there
  • Elsewhere the host's own daemon is left alone and judged by NTPSynchronized=yes
  • Check mode warns when nothing keeps time (CanNTP=no and not synchronized)
  • A deploy that waits 60 seconds without synchronizing fails with a message naming the daemons to check, instead of the retry loop's bare command result

Installing systemd-timesyncd on those hosts was not an option: it would run beside ntp/ntpsec and fight over the clock.

Test plan

  • engine/tests/test_time_role.py: replays the role's when and assert expressions through Ansible's own templating for four host states (timesyncd on, timesyncd off, another daemon synchronized, nothing keeps time) in check and live mode; 4 of the 6 tests fail on the old role
  • uv run pytest (448 passed), ruff, mypy, ansible-lint (production profile), time.yml --syntax-check
  • Check-mode run of this branch's role against all six atlas-fleet servers: changed=0 on every host
  • After merge and a fleet pin bump, task time:check on atlas-fleet shows changed=0

🤖 Generated with Claude Code

`timedatectl set-ntp` switches systemd-timesyncd and nothing else. On a
host whose clock ntp, ntpsec, or chrony keeps, timedatectl reports
CanNTP=no and NTP=no while NTPSynchronized=yes, so the role called the
host drifted: check mode reported "Would enable network time
synchronization" and a deploy failed with "Failed to set ntp: NTP not
supported". Four of the six atlas-fleet servers (Debian 11 and 12 on
ntp/ntpsec) hit it.

The role now reads CanNTP, switches NTP on only where systemd-timesyncd
is installed, and otherwise requires NTPSynchronized=yes. Check mode
warns when nothing keeps time; a deploy that waits 60 seconds without
synchronizing fails with a message naming the daemons to check, rather
than the retry loop's bare command result.

Tests replay the role's when and assert expressions through Ansible's
own templating for four host states; the other-daemon case fails on the
old role. A check-mode run of this role against all six fleet servers
reports changed=0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@romamo
romamo merged commit 6f3dfca into main Sep 30, 2026
1 check passed
@romamo
romamo deleted the fix/time-role-any-ntp-daemon branch September 30, 2026 10:36
@shipmill-romamo shipmill-romamo Bot added this to the 0.6.0 milestone Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant