geerlingguy / ansible-role-ntp

Ansible Role - NTP
https://galaxy.ansible.com/geerlingguy/ntp/
MIT License
318 stars 241 forks source link

NTP service not working when Debian 11 VM restarts #121

Closed staticdev closed 11 months ago

staticdev commented 1 year ago

I decided to open an issue since other users may be having the same when installing NTP with this role.

Restarted VM shows status failed on systemctl status ntp.

Logs from boot journalctl -b -u ntp:

-- Journal begins at Sun 2022-12-04 14:33:50 UTC, ends at Sun 2023-01-15 14:05:35 UTC. --
Jan 14 18:55:39 login systemd[1]: Starting Network Time Service...
Jan 14 18:55:39 login ntpd[357]: ntpd 4.2.8p15@1.3728-o Wed Sep 23 11:46:38 UTC 2020 (1): Starting
Jan 14 18:55:39 login ntpd[357]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 107:111
Jan 14 18:55:39 login ntpd[357]: ----------------------------------------------------
Jan 14 18:55:39 login ntpd[357]: ntp-4 is maintained by Network Time Foundation,
Jan 14 18:55:39 login ntpd[357]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
Jan 14 18:55:39 login ntpd[357]: corporation.  Support and training for ntp-4 are
Jan 14 18:55:39 login ntpd[357]: available at https://www.nwtime.org/support
Jan 14 18:55:39 login ntpd[357]: ----------------------------------------------------
Jan 14 18:55:39 login ntpd[375]: proto: precision = 0.100 usec (-23)
Jan 14 18:55:39 login ntpd[375]: basedate set to 2020-09-11
Jan 14 18:55:39 login ntpd[375]: gps base set to 2020-09-13 (week 2123)
Jan 14 18:55:39 login ntpd[375]: leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): good hash signature
Jan 14 18:55:39 login ntpd[375]: leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): loaded, expire=2023-06-28T00:00:00Z last=2017>
Jan 14 18:55:39 login ntpd[375]: Listen and drop on 0 v6wildcard [::]:123
Jan 14 18:55:39 login ntpd[375]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Jan 14 18:55:39 login ntpd[375]: Listen normally on 2 lo 127.0.0.1:123
Jan 14 18:55:39 login ntpd[375]: Listen normally on 3 lo [::1]:123
Jan 14 18:55:39 login ntpd[375]: bind(20) AF_INET6 fe80::5054:ff:fe38:9dbe%2#123 flags 0x11 failed: Cannot assign requested address
Jan 14 18:55:39 login ntpd[375]: unable to create socket on ens3 (4) for fe80::5054:ff:fe38:9dbe%2#123
Jan 14 18:55:39 login ntpd[375]: failed to init interface for address fe80::5054:ff:fe38:9dbe%2
Jan 14 18:55:39 login ntpd[375]: Listening on routing socket on fd #20 for interface updates
Jan 14 18:55:39 login ntpd[375]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
Jan 14 18:55:39 login ntpd[375]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
Jan 14 18:55:39 login systemd[1]: Started Network Time Service.

Any ideas what may cause this?

staticdev commented 1 year ago

After some research I found a solution, add to /lib/systemd/system/ntp.service:

[Service]
# ...
Restart=on-failure
RestartSec=5s

Apparently Debian ntp service will stop itself when meeting some constraints: eg. time difference is huge, or timezone is difference.

Maybe a nice enhancement to add optinal restart in this role.

staticdev commented 1 year ago

@geerlingguy I made a PR with the solution I am currently using on my Debian servers. Would appreciate if you can evaluate it for adding back to your original role.

github-actions[bot] commented 1 year ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

github-actions[bot] commented 11 months ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.