1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# This class ensures ntp is up'n running and synchronizing with ntp servers.
class timezone {
case $ntp_timezone {
'': { fail("you need to define \$ntp_timezone for ntp module") }
}
# the needed packages
package { "tzdata": ensure => installed, }
# adjust localtime
file { "/etc/localtime":
ensure => "/usr/share/zoneinfo/${ntp_timezone}",
require => Package["tzdata"],
}
# don't adjust time using ntpdate
cron { "ntpdate":
ensure => absent,
}
}
class ntp inherits timezone {
case $ntp_servers {
'': { fail("you need to define \$ntp_servers for ntp module") }
}
# the needed packages
package { "ntp": ensure => installed, }
# ntp service
service { "ntp":
enable => true,
ensure => running,
hasrestart => true,
require => [ Package["ntp"], File["/etc/ntp.drift"], File["/etc/ntp.conf"] ],
}
# the /etc/ntp.drift file contains the latest estimate of clock frequency
# error.
file { "/etc/ntp.drift":
owner => "root",
group => "root",
mode => 0644,
ensure => present,
}
# ntp configuration file
file { "/etc/ntp.conf":
content => template('ntp/ntp.conf.erb'),
owner => "root",
group => "root",
mode => 0644,
ensure => present,
notify => Service["ntp"],
}
}
class ntpdate inherits timezone {
# TODO: add logrotate rule to /var/log/ntpdate.log
case $ntp_pool {
'': { fail("you need to define \$ntp_pool for ntp module") }
}
# the needed packages
package { "ntpdate":
ensure => present,
}
# adjust time using ntpdate
Cron["ntpdate"] {
command => "/usr/sbin/ntpdate -t 5 ${ntp_pool} >> /var/log/ntpdate.log 2>&1",
user => root,
hour => "*/1",
minute => "10",
ensure => present,
require => Package["ntpdate"],
}
# ensure ntp service is stopped
service { "ntp":
enable => false,
ensure => false,
}
}
|