Fix ntp configuration for noble
Related-Prod: PRODX-3456
Change-Id: I71965f465e4d097f70a3d17ae1bc72ffd02a8d7e
diff --git a/de/heat-templates/scripts/functions.sh b/de/heat-templates/scripts/functions.sh
index b8bde38..18db32f 100644
--- a/de/heat-templates/scripts/functions.sh
+++ b/de/heat-templates/scripts/functions.sh
@@ -201,7 +201,11 @@
}
function install_required_packages {
- local pkg_list="apt-transport-https ca-certificates curl software-properties-common jq unzip atop iptables-persistent socat ntp rng-tools open-iscsi nfs-common"
+ local pkg_list="apt-transport-https ca-certificates curl software-properties-common jq unzip atop iptables-persistent socat rng-tools open-iscsi nfs-common"
+
+ if [[ ${CODENAME} == "bionic" ]] || [[ ${CODENAME} == "focal" ]] || [[ ${CODENAME} == "jammy" ]]; then
+ pkg_list="$pkg_list ntp"
+ fi
if [[ "${DPDK_ENABLED}" == true ]]; then
# Since jammy the igb_uio kernel module contains in the dpdk-kmods-dkms package
@@ -541,15 +545,9 @@
function configure_ntp {
if [[ ${CODENAME} == "bionic" ]] || [[ ${CODENAME} == "focal" ]] || [[ ${CODENAME} == "jammy" ]]; then
- local ntp_conf="/etc/ntp.conf"
- local ntp_driftfile="/var/lib/ntp/ntp.drift"
local ntp_service_name="ntp"
- else
- local ntp_conf="/etc/ntpsec/ntp.conf"
- local ntp_driftfile="/var/lib/ntpsec/ntp.drift"
- local ntp_service_name="ntpsec"
- fi
- echo "" > ${ntp_conf}
+
+ echo "" > ${ntp_conf}
for server in $NTP_SERVERS; do
cat << EOF >> ${ntp_conf}
@@ -557,7 +555,7 @@
EOF
done
- cat << EOF >> ${ntp_conf}
+ cat << EOF >> /etc/ntp.conf
# Set general access to this service
restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
@@ -572,12 +570,19 @@
interface listen ${DEFAULT_INTERFACE}
# Location of drift file
-driftfile ${ntp_driftfile}
+driftfile /var/lib/ntp/ntp.drift
EOF
- if systemctl --quiet is-enabled systemd-timesyncd ; then
- systemctl disable systemd-timesyncd
+ else
+ local ntp_service_name="systemd-timesyncd "
+ local ntp_servers_string=""
+ cat <<EOF> /etc/systemd/timesyncd.conf
+[Time]
+NTP=$NTP_SERVERS
+FallbackNTP=0.pool.ntp.org 1.pool.ntp.org 0.fr.pool.ntp.org
+EOF
fi
+
systemctl enable ${ntp_service_name}
systemctl restart ${ntp_service_name}
}