Skip to content

Commit 626737b

Browse files
committed
Add support for ntpsec
1 parent 5988ba0 commit 626737b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

docs/advanced/ntp.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,10 @@ Force sync time immediately by NTP after the ntp installed, which is useful in n
4848
```ShellSession
4949
ntp_force_sync_immediately: true
5050
```
51+
52+
When using Ubuntu 24.04 or a distribution that already has `systemd-timesyncd` installed, use the `ntpsec` package.
53+
54+
```ShellSession
55+
ntp_package: ntpsec
56+
ntp_driftfile: /var/lib/ntpsec/ntp.drift
57+
```

roles/kubernetes/preinstall/defaults/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ping_access_ip: true
6464
ntp_enabled: false
6565
# The package to install which provides NTP functionality.
6666
# The default is ntp for most platforms, or chrony on RHEL/CentOS 7 and later.
67-
# The ntp_package can be one of ['ntp', 'chrony']
67+
# The ntp_package can be one of ['ntp', 'ntpsec', 'chrony']
6868
ntp_package: >-
6969
{% if ansible_os_family == "RedHat" -%}
7070
chrony
@@ -95,6 +95,7 @@ ntp_filter_interface: false
9595
# - listen xxx
9696
# The NTP driftfile path
9797
# Only takes effect when ntp_manage_config is true.
98+
# For ntpsec use '/var/lib/ntpsec/ntp.drift'
9899
ntp_driftfile: /var/lib/ntp/ntp.drift
99100
# Enable tinker panic is useful when running NTP in a VM environment.
100101
# Only takes effect when ntp_manage_config is true.

roles/kubernetes/preinstall/tasks/0081-ntp-configurations.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
ntp_config_file: >-
2222
{% if ntp_package == "ntp" -%}
2323
/etc/ntp.conf
24+
{%- elif ntp_package == "ntpsec" -%}
25+
/etc/ntpsec/ntp.conf
2426
{%- elif ansible_os_family in ['RedHat', 'Suse'] -%}
2527
/etc/chrony.conf
2628
{%- else -%}
@@ -56,10 +58,10 @@
5658
# noqa: jinja[spacing]
5759
command: >-
5860
timeout -k 60s 60s
59-
{% if ntp_package == "ntp" -%}
60-
ntpd -gq
61-
{%- else -%}
61+
{% if ntp_package == "chrony" -%}
6262
chronyd -q
63+
{%- else -%}
64+
ntpd -gq
6365
{%- endif -%}
6466
when:
6567
- ntp_force_sync_immediately

0 commit comments

Comments
 (0)