summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshley Penney <ashley.penney@puppetlabs.com>2013-07-05 19:18:20 -0400
committerAshley Penney <ashley.penney@puppetlabs.com>2013-07-05 19:21:45 -0400
commit82057592fe4e83ed15f1b5a9d4cd652fd0b8e528 (patch)
treeeee45a7edd8ce56cf1790a2a2adabe16f2fe5ca6
parent1a199c77dff8569927c65544185f92dfb0a15c46 (diff)
Add Gentoo support. (And reformat archlinux vars)
-rw-r--r--Modulefile2
-rw-r--r--manifests/params.pp20
-rw-r--r--spec/classes/ntp_spec.rb19
-rw-r--r--templates/ntp.conf.gentoo.erb54
4 files changed, 90 insertions, 5 deletions
diff --git a/Modulefile b/Modulefile
index 3b18895..7755b15 100644
--- a/Modulefile
+++ b/Modulefile
@@ -4,7 +4,7 @@ source 'git://github.com/puppetlabs/puppetlabs-ntp'
author 'Puppet Labs'
license 'Apache Version 2.0'
summary 'NTP Module'
-description 'NTP Module for Debian, Ubuntu, CentOS, RHEL, OEL, Fedora, FreeBSD & Arch'
+description 'NTP Module for Debian, Ubuntu, CentOS, RHEL, OEL, Fedora, FreeBSD, ArchLinux and Gentoo.'
project_page 'http://github.com/puppetlabs/puppetlabs-ntp'
## Add dependencies, if any:
diff --git a/manifests/params.pp b/manifests/params.pp
index 91186da..1a9b7c8 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -62,16 +62,28 @@ class ntp::params() {
# Account for distributions that don't have $::osfamily specific settings.
case $::operatingsystem {
'Archlinux': {
- $config = '/etc/ntp.conf'
+ $config = '/etc/ntp.conf'
$config_template = 'ntp/ntp.conf.archlinux.erb'
- $package_name = ['ntp']
- $service_name = 'ntpd'
- $servers = [
+ $package_name = ['ntp']
+ $service_name = 'ntpd'
+ $servers = [
'0.pool.ntp.org',
'1.pool.ntp.org',
'2.pool.ntp.org',
]
}
+ 'Gentoo': {
+ $config = '/etc/ntp.conf'
+ $config_template = 'ntp/ntp.conf.gentoo.erb'
+ $package_name = ['net-misc/ntp']
+ $service_name = 'ntpd'
+ $servers = [
+ '0.gentoo.pool.ntp.org',
+ '1.gentoo.pool.ntp.org',
+ '2.gentoo.pool.ntp.org',
+ '3.gentoo.pool.ntp.org',
+ ]
+ }
default: {
fail("The ${module_name} module is not supported on an ${::operatingsystem} distribution.")
}
diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb
index c70908a..527c53f 100644
--- a/spec/classes/ntp_spec.rb
+++ b/spec/classes/ntp_spec.rb
@@ -123,6 +123,25 @@ describe 'ntp' do
end
end
+ describe "for operating system Gentoo" do
+
+ let(:params) {{}}
+ let(:facts) { { :operatingsystem => 'Gentoo',
+ :osfamily => 'Linux' } }
+
+ it { should contain_service('ntp').with_name('ntpd') }
+ it { should contain_package('ntp').with_name('net-misc/ntp').with_ensure('present') }
+
+ it 'should use the NTP pool servers by default' do
+ content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
+ expected_lines = [
+ "server 0.gentoo.pool.ntp.org",
+ "server 1.gentoo.pool.ntp.org",
+ "server 2.gentoo.pool.ntp.org",
+ "server 3.gentoo.pool.ntp.org"]
+ (content.split("\n") & expected_lines).should == expected_lines
+ end
+ end
['Debian', 'RedHat','SuSE', 'FreeBSD'].each do |osfamily|
describe "for operating system family #{osfamily}" do
diff --git a/templates/ntp.conf.gentoo.erb b/templates/ntp.conf.gentoo.erb
new file mode 100644
index 0000000..7b00b46
--- /dev/null
+++ b/templates/ntp.conf.gentoo.erb
@@ -0,0 +1,54 @@
+# NOTES:
+# DHCP clients can append or replace NTP configuration files.
+# You should consult your DHCP client documentation about its
+# default behaviour and how to change it.
+
+# Name of the servers ntpd should sync with
+# Please respect the access policy as stated by the responsible person.
+#server ntp.example.tld iburst
+
+# Managed by puppet class { "ntp": servers => [ ... ] }
+<% [@servers].flatten.each do |server| -%>
+server <%= server %>
+<% end -%>
+
+# Common pool for random people
+#server pool.ntp.org
+
+##
+# A list of available servers can be found here:
+# http://www.pool.ntp.org/
+# http://www.pool.ntp.org/#use
+# A good way to get servers for your machine is:
+# netselect -s 3 pool.ntp.org
+##
+
+# you should not need to modify the following paths
+driftfile /var/lib/ntp/ntp.drift
+
+#server ntplocal.example.com prefer
+#server timeserver.example.org
+
+# Warning: Using default NTP settings will leave your NTP
+# server accessible to all hosts on the Internet.
+
+# If you want to deny all machines (including your own)
+# from accessing the NTP server, uncomment:
+#restrict default ignore
+
+
+<% if @restrict -%>
+# To deny other machines from changing the
+# configuration but allow localhost:
+restrict default nomodify nopeer
+restrict 127.0.0.1
+restrict ::1
+<% end -%>
+
+
+# To allow machines within your network to synchronize
+# their clocks with your server, but ensure they are
+# not allowed to configure the server or used as peers
+# to synchronize against, uncomment this line.
+#
+#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap