From 57783f3007fcd65679370c871114494bf8ec07ac Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 2 Dec 2013 21:15:11 -0500 Subject: [PATCH] Add sample NTP programs --- files/ntp.conf.debian | 56 ++++++++++++++++++++++++++++++ files/ntp.conf.redhat | 51 +++++++++++++++++++++++++++ manifests/7-full-example.pp | 16 +++++++++ manifests/8-independent-example.pp | 32 +++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 files/ntp.conf.debian create mode 100644 files/ntp.conf.redhat create mode 100644 manifests/7-full-example.pp create mode 100644 manifests/8-independent-example.pp diff --git a/files/ntp.conf.debian b/files/ntp.conf.debian new file mode 100644 index 0000000..2491c97 --- /dev/null +++ b/files/ntp.conf.debian @@ -0,0 +1,56 @@ +# /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 ntp.your-provider.example + +# 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: + +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 + +# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for +# details. The web page +# might also be helpful. +# +# Note that "restrict" applies to both servers and clients, so a configuration +# that might be intended to block requests from certain clients could also end +# up blocking replies from your own upstream servers. + +# 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 + +# Clients from this (example!) subnet have unlimited access, but only if +# cryptographically authenticated. +#restrict 192.168.123.0 mask 255.255.255.0 notrust + + +# If you want to provide time to your local subnet, change the next line. +# (Again, the address is an example only.) +#broadcast 192.168.123.255 + +# If you want to listen to time broadcasts on your local subnet, de-comment the +# next lines. Please do this only if you trust everybody on the network! +#disable auth +#broadcastclient + diff --git a/files/ntp.conf.redhat b/files/ntp.conf.redhat new file mode 100644 index 0000000..69dfc7d --- /dev/null +++ b/files/ntp.conf.redhat @@ -0,0 +1,51 @@ +# Permit time synchronization with our time source, but do not +# permit the source to query or modify the service on this system. +restrict default kod nomodify notrap nopeer noquery +restrict -6 default kod nomodify notrap nopeer noquery + +# Permit all access over the loopback interface. This could +# be tightened as well, but to do so would effect some of +# the administrative functions. +restrict 127.0.0.1 +restrict -6 ::1 + +# Hosts on local network are less restricted. +#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap + +# Use public servers from the pool.ntp.org project. +# Please consider joining the pool (http://www.pool.ntp.org/join.html). + +server 0.centos.pool.ntp.org +server 1.centos.pool.ntp.org +server 2.centos.pool.ntp.org + +#broadcast 192.168.1.255 key 42 # broadcast server +#broadcastclient # broadcast client +#broadcast 224.0.1.1 key 42 # multicast server +#multicastclient 224.0.1.1 # multicast client +#manycastserver 239.255.254.254 # manycast server +#manycastclient 239.255.254.254 key 42 # manycast client + +# Undisciplined Local Clock. This is a fake driver intended for backup +# and when no outside source of synchronized time is available. +server 127.127.1.0 # local clock +fudge 127.127.1.0 stratum 10 + +# Drift file. Put this in a directory which the daemon can write to. +# No symbolic links allowed, either, since the daemon updates the file +# by creating a temporary in the same directory and then rename()'ing +# it to the file. +driftfile /var/lib/ntp/drift + +# Key file containing the keys and key identifiers used when operating +# with symmetric key cryptography. +keys /etc/ntp/keys + +# Specify the key identifiers which are trusted. +#trustedkey 4 8 42 + +# Specify the key identifier to use with the ntpdc utility. +#requestkey 8 + +# Specify the key identifier to use with the ntpq utility. +#controlkey 8 diff --git a/manifests/7-full-example.pp b/manifests/7-full-example.pp new file mode 100644 index 0000000..3e8b98d --- /dev/null +++ b/manifests/7-full-example.pp @@ -0,0 +1,16 @@ +package { 'ntp': + ensure => present, +} + +file { '/etc/ntp.conf': + ensure => present, + require => Package['ntp'], + source => '/vagrant/files/ntp.conf.debian', +} + +service { 'ntp': + ensure => running, + enable => true, + subscribe => File['/etc/ntp.conf'], +} + diff --git a/manifests/8-independent-example.pp b/manifests/8-independent-example.pp new file mode 100644 index 0000000..440fdab --- /dev/null +++ b/manifests/8-independent-example.pp @@ -0,0 +1,32 @@ +case $::osfamily { + 'RedHat': { + $service = 'ntpd' + $conf = 'ntp.conf.redhat' + } + 'Debian': { + $service = 'ntp' + $conf = 'ntp.conf.debian' + } +} + +notify { 'OS Information': + message => "${::osfamily}: Setting service to ${service} and conf to ${conf}", + before => Package['ntp'], +} + +package { 'ntp': + ensure => present, +} + +file { '/etc/ntp.conf': + ensure => present, + require => Package['ntp'], + source => "/vagrant/files/${conf}", +} + +service { $service: + ensure => running, + enable => true, + subscribe => File['/etc/ntp.conf'], +} +