Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ntpsec #11665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/advanced/ntp.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ Force sync time immediately by NTP after the ntp installed, which is useful in n
```ShellSession
ntp_force_sync_immediately: true
```

When using Ubuntu 24.04 or a distribution that already has `systemd-timesyncd` installed, use the `ntpsec` package.

```ShellSession
ntp_package: ntpsec
ntp_driftfile: /var/lib/ntpsec/ntp.drift
```
3 changes: 2 additions & 1 deletion roles/kubernetes/preinstall/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ping_access_ip: true
ntp_enabled: false
# The package to install which provides NTP functionality.
# The default is ntp for most platforms, or chrony on RHEL/CentOS 7 and later.
# The ntp_package can be one of ['ntp', 'chrony']
# The ntp_package can be one of ['ntp', 'ntpsec', 'chrony']
ntp_package: >-
{% if ansible_os_family == "RedHat" -%}
chrony
Expand Down Expand Up @@ -95,6 +95,7 @@ ntp_filter_interface: false
# - listen xxx
# The NTP driftfile path
# Only takes effect when ntp_manage_config is true.
# For ntpsec use '/var/lib/ntpsec/ntp.drift'
ntp_driftfile: /var/lib/ntp/ntp.drift
# Enable tinker panic is useful when running NTP in a VM environment.
# Only takes effect when ntp_manage_config is true.
Expand Down
8 changes: 5 additions & 3 deletions roles/kubernetes/preinstall/tasks/0081-ntp-configurations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
ntp_config_file: >-
{% if ntp_package == "ntp" -%}
/etc/ntp.conf
{%- elif ntp_package == "ntpsec" -%}
/etc/ntpsec/ntp.conf
{%- elif ansible_os_family in ['RedHat', 'Suse'] -%}
/etc/chrony.conf
{%- else -%}
Expand Down Expand Up @@ -56,10 +58,10 @@
# noqa: jinja[spacing]
command: >-
timeout -k 60s 60s
{% if ntp_package == "ntp" -%}
ntpd -gq
{%- else -%}
{% if ntp_package == "chrony" -%}
chronyd -q
{%- else -%}
ntpd -gq
{%- endif -%}
when:
- ntp_force_sync_immediately
Expand Down