stuvusIT / ansible_systemd_timesyncd

Ansible role to set timezone and configure systemd-timesyncd
Other
18 stars 23 forks source link

Role fails on devices without realtime clock #9

Open dschanoeh opened 4 years ago

dschanoeh commented 4 years ago

Hi,

I just ran this role against a pizero which doesn't have a RTC. In that case, the "Write adjtime" handler fails:

hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.

To fix, one could either:

  1. Add a variable "skip_rtc_update" or similar to skip the handler
  2. Try to detect if /dev/rtc exists and skip the handler if it doesn't
  3. Add a variable to specify the RTC device and a special value to skip RTC updates

I could create a PR for one of those options.

dasJ commented 4 years ago

What about having something like timesync_rtc_set: true with a tri-state value of false (no update is attempted), true (an update is attempted if /dev/rtc exists), and force (role fails if /dev/rtc does not exist).

There is no reason why we wouldn't specify the RTC device, but I don't think (maybe I'm wrong) the path is different on different kernels.

dschanoeh commented 4 years ago

The documentation indicates that it could also be /dev/rtc0, /dev/rtc1, etc. So maybe it wouldn't hurt to have a variable as well. I'm almost done implementing the tri-state variable but having read more of the documentation, I'm now wondering:

  1. Doesn't timesyncd already automatically adjust the RTC? What's the purpose of that additional sync?
  2. But assuming that sync is useful, shouldn't it wait for the system time to actually be synchronized? I think that could take a few seconds... Status can be checked using timedatectl | grep "NTP synchronized". Should I add that as well?