diff --git a/hshbase/time/files/ntp.conf b/hshbase/time/files/ntp.conf deleted file mode 100644 index b69b6589374eb11669ac3a1cb33fbc7de97bfc7a..0000000000000000000000000000000000000000 --- a/hshbase/time/files/ntp.conf +++ /dev/null @@ -1,35 +0,0 @@ -{%- from "hshbase/map.jinja" import hshbase with context -%} -### THIS FILE IS MANAGED BY SALT! -### YOUR CHANGES WILL BE OVERWRITTEN! -# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help - -driftfile /var/lib/ntp/ntp.drift - - -# Enable this if you want statistics to be logged. -#statsdir /var/log/ntpstats/ - -statistics loopstats peerstats clockstats -filegen loopstats file loopstats type day enable -filegen peerstats file peerstats type day enable -filegen clockstats file clockstats type day enable - - -# You do need to talk to an NTP server or two (or three). -server {{ hshbase['time']['server'] }} iburst - -# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will -# pick a different set every time it starts up. Please consider joining the -# pool: <http://www.pool.ntp.org/join.html> -server 0.debian.pool.ntp.org iburst -server 1.debian.pool.ntp.org iburst -server 2.debian.pool.ntp.org iburst -server 3.debian.pool.ntp.org iburst - -# By default, exchange time with everybody, but don't allow configuration. -restrict -4 default kod notrap nomodify nopeer noquery -restrict -6 default kod notrap nomodify nopeer noquery - -# Local users may interrogate the ntp server more closely. -restrict 127.0.0.1 -restrict ::1 diff --git a/hshbase/time/files/timesyncd.conf b/hshbase/time/files/timesyncd.conf new file mode 100644 index 0000000000000000000000000000000000000000..d0728d0270b7667eb00cd1c5374e1b2eea6aac19 --- /dev/null +++ b/hshbase/time/files/timesyncd.conf @@ -0,0 +1,21 @@ +### THIS FILE IS MANAGED BY SALT via `hshbase` formula! YOUR CHANGES WILL BE OVERWRITTEN! +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# Entries in this file show the compile time defaults. +# You can change settings by editing this file. +# Defaults can be restored by simply deleting this file. +# +# See timesyncd.conf(5) for details. + +[Time] +NTP=time.hs-hannover.de +#FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org +#RootDistanceMaxSec=5 +#PollIntervalMinSec=32 +#PollIntervalMaxSec=2048 diff --git a/hshbase/time/init.sls b/hshbase/time/init.sls index 8e055942731fd03e24d49004eaffc7af21d90345..b091ba6f9df0ecbfa41e39f080193b68a4d9630c 100644 --- a/hshbase/time/init.sls +++ b/hshbase/time/init.sls @@ -1,24 +1,43 @@ {% from "hshbase/map.jinja" import hshbase with context %} -{% if (grains['os'] == 'Debian' and grains['osmajorrelease'] >= 10) or grains['os'] == 'Ubuntu' and grains['osmajorrelease'] >= 18 %} +hsh_server_timezone: + timezone.system: + - name: {{ hshbase.time.zone }} -ntp: - pkg.purged -/etc/ntp.conf: +hsh_remove_ntp_config: file.absent: - - require: - - pkg: ntp + - name: /etc/ntp.conf hsh_ntp_service_not_running: service.disabled: - name: ntp + +hsh_purge_ntp: + pkg.purged: + - name: ntp - require: - - file: /etc/ntp.conf - - pkg: ntp + - file: hsh_remove_ntp_config + - service: hsh_ntp_service_not_running -{% endif %} -hsh_server_timezone: - timezone.system: - - name: {{ hshbase.time.zone }} +hsh_systemd_timesyncd_present: + pkg.install: + - name: systemd-timesyncd + +hsh_systemd_timesyncd_configured: + file.managed: + - name: /etc/systemd/timesyncd.conf + - source: salt://hshbase-formula/hshbase/time/timesyncd.conf + - require: + - pkg: hsh_systemd_timesyncd_present + +hsh_systemd_timesyncd_service_running: + service.running: + - name: systemd-timesyncd + - enabled: True + - restart: True + - require: + - file: hsh_systemd_timesyncd_configured + - watch: + - file: hsh_systemd_timesyncd_configured