Skip to content

Commit 2e0d207

Browse files
author
Will Hopper
committed
(#14457) Add FreeBSD support for the NTP class
1 parent 0b39d32 commit 2e0d207

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

README.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ This module has been built and tested using Puppet 2.6.x
99
* Enterprise Linux 5
1010
* Ubuntu 10.04 Lucid
1111
* Amazon Linux 2011.09 has been tested on 2.7.x with facter version 1.6.2
12-
12+
* FreeBSD 9.0

manifests/init.pp

+18-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# - Debian 6.0 Squeeze
1010
# - CentOS 5.4
1111
# - Amazon Linux 2011.09
12+
# - FreeBSD 9.0
1213
#
1314
# Parameters:
1415
#
@@ -78,6 +79,21 @@
7879
$servers_real = $servers
7980
}
8081
}
82+
freebsd: {
83+
$supported = true
84+
$pkg_name = [".*/net/ntp"]
85+
$svc_name = "ntpd"
86+
$config = "/etc/ntp.conf"
87+
$config_tpl = "ntp.conf.freebsd.erb"
88+
if ($servers == "UNSET") {
89+
$servers_real = [ "0.freebsd.pool.ntp.org iburst maxpoll 9",
90+
"1.freebsd.pool.ntp.org iburst maxpoll 9",
91+
"2.freebsd.pool.ntp.org iburst maxpoll 9",
92+
"3.freebsd.pool.ntp.org iburst maxpoll 9", ]
93+
} else {
94+
$servers_real = $servers
95+
}
96+
}
8197
default: {
8298
$supported = false
8399
notify { "${module_name}_unsupported":
@@ -88,7 +104,8 @@
88104

89105
if ($supported == true) {
90106

91-
package { $pkg_name:
107+
package { "ntp":
108+
name => $pkg_name,
92109
ensure => $package_ensure,
93110
}
94111

spec/classes/ntp_spec.rb

+21-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def param_value(subject, type, title, param)
1313

1414
debianish = ['debian', 'ubuntu']
1515
redhatish = ['centos', 'redhat', 'oel', 'linux']
16+
bsdish = ['freebsd']
1617

1718
debianish.each do |os|
1819
describe "for operating system #{os}" do
@@ -50,7 +51,26 @@ def param_value(subject, type, title, param)
5051
end
5152
end
5253

53-
(redhatish + debianish).each do |os|
54+
bsdish.each do |os|
55+
describe "for operating system #{os}" do
56+
57+
let(:params) {{}}
58+
let(:facts) { { :operatingsystem => os } }
59+
60+
it { should contain_service('ntp').with_name('ntpd') }
61+
it 'should use the freebsd ntp servers by default' do
62+
content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
63+
expected_lines = [
64+
"server 0.freebsd.pool.ntp.org iburst maxpoll 9",
65+
"server 1.freebsd.pool.ntp.org iburst maxpoll 9",
66+
"server 2.freebsd.pool.ntp.org iburst maxpoll 9",
67+
"server 3.freebsd.pool.ntp.org iburst maxpoll 9"]
68+
(content.split("\n") & expected_lines).should == expected_lines
69+
end
70+
end
71+
end
72+
73+
(redhatish + debianish + bsdish).each do |os|
5474
describe "for operating system #{os}" do
5575

5676
let(:facts) { { :operatingsystem => os } }

templates/ntp.conf.freebsd.erb

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# $FreeBSD: release/9.0.0/etc/ntp.conf 195652 2009-07-13 05:51:33Z dwmalone $
3+
#
4+
# Default NTP servers for the FreeBSD operating system.
5+
#
6+
# Don't forget to enable ntpd in /etc/rc.conf with:
7+
# ntpd_enable="YES"
8+
#
9+
# The driftfile is by default /var/db/ntpd.drift, check
10+
# /etc/defaults/rc.conf on how to change the location.
11+
#
12+
#
13+
# See http://www.pool.ntp.org/ for details. Note, the pool encourages
14+
# users with a static IP and good upstream NTP servers to add a server
15+
# to the pool. See http://www.pool.ntp.org/join.html if you are interested.
16+
#
17+
# The option `iburst' is used for faster initial synchronisation.
18+
# The option `maxpoll 9' is used to prevent PLL/FLL flipping on FreeBSD.
19+
#
20+
# Managed by puppet class { "ntp": servers => [ ... ] }
21+
<% [servers_real].flatten.each do |server| -%>
22+
server <%= server %>
23+
<% end -%>

0 commit comments

Comments
 (0)