From 520ed18f40df20ab2014fbbfb411e2641ed58345 Mon Sep 17 00:00:00 2001 From: Andreas Kempe <kempe@lysator.liu.se> Date: Thu, 14 Apr 2022 19:15:34 +0200 Subject: [PATCH] ntp_server: add class for configuring the NTP server Configures chrony and gpsd to use the GPS on /dev/ttyS0 and the PPS on /dev/pps0. --- files/chrony/chrony.conf | 26 ++++++++++++++++++++++++++ files/gpsd/conf | 3 +++ manifests/ntp_server.pp | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 files/chrony/chrony.conf create mode 100644 files/gpsd/conf create mode 100644 manifests/ntp_server.pp diff --git a/files/chrony/chrony.conf b/files/chrony/chrony.conf new file mode 100644 index 0000000..00ea774 --- /dev/null +++ b/files/chrony/chrony.conf @@ -0,0 +1,26 @@ +# NOTE: This file is managed by the timehost::ntp_server puppet class. +# Use public NTP servers from the pool.ntp.org project. +#pool pool.ntp.org iburst + +# Backup ntp.se Stockholm servers. +server sth1.ntp.se +server sth2.ntp.se +server sth3.ntp.se +server sth4.ntp.se + +# Record the rate at which the system clock gains/losses time. +driftfile /var/lib/chrony/drift + +# Allow the system clock to be stepped in the first three updates +# if its offset is larger than 1 second. +makestep 1.0 3 + +# Enable kernel synchronization of the real-time clock (RTC). +rtcsync + +bindaddress 130.236.254.17 +bindaddress 2001:6b0:17:f0a0::11 +allow + +refclock SHM 0 refid GPS precision 1e-1 offset 0.9999 +refclock SHM 2 refid PPS precision 1e-7 diff --git a/files/gpsd/conf b/files/gpsd/conf new file mode 100644 index 0000000..156d25b --- /dev/null +++ b/files/gpsd/conf @@ -0,0 +1,3 @@ +# NOTE: This file is managed by the timehost::ntp_server class. +DEV="/dev/ttyS0 /dev/pps0" +OPTS="-n" diff --git a/manifests/ntp_server.pp b/manifests/ntp_server.pp new file mode 100644 index 0000000..5f0bb21 --- /dev/null +++ b/manifests/ntp_server.pp @@ -0,0 +1,39 @@ +# NTP server configuration. +class timehost::ntp_server { + package { + [ + 'chrony', + 'gpsd', + ]: + ensure => installed, + } + + service { 'gpsd': + ensure => running, + enable => true, + } + + file { '/etc/sv/gpsd/conf': + ensure => present, + source => 'puppet:///modules/timehost/gpsd/conf', + owner => 'root', + group => 'root', + mode => '0644', + notify => Service['gpsd'], + } + + service { 'chronyd': + ensure => running, + enable => true, + notify => Service['gpsd'], + } + + file { '/etc/chrony.conf': + ensure => present, + source => 'puppet:///modules/timehost/chrony/chrony.conf', + owner => 'root', + group => 'root', + mode => '0644', + notify => Service['chronyd'], + } +} -- GitLab