summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-01-24 22:39:31 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-01-24 22:39:31 -0200
commit063b83207c6fac682c4089844e1a5524d8006205 (patch)
treee759f604fc30c9243686ae62dfed4d6553f12ef1
parent1775ab5fb521c89f3df288341a0598f1edfaf1a1 (diff)
downloadpuppet-ntp-063b83207c6fac682c4089844e1a5524d8006205.tar.gz
puppet-ntp-063b83207c6fac682c4089844e1a5524d8006205.tar.bz2
Using hiera and parametrized classes
-rw-r--r--manifests/init.pp30
-rw-r--r--templates/ntp.conf.erb2
2 files changed, 20 insertions, 12 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 3e7e4e3..a980efb 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,9 +1,11 @@
# This class ensures ntp is up'n running and synchronizing with ntp servers.
-class timezone {
+class timezone(
+ $zone = hiera('ntp::zone', '')
+) {
- case $ntp_timezone {
- '': { fail("you need to define \$ntp_timezone for ntp module") }
+ case $zone {
+ '': { fail("you need to define ntp::zone for ntp module") }
}
# the needed packages
@@ -11,15 +13,18 @@ class timezone {
# adjust localtime
file { "/etc/localtime":
- ensure => "/usr/share/zoneinfo/${ntp_timezone}",
+ ensure => "/usr/share/zoneinfo/${zone}",
require => Package["tzdata"],
}
}
-class ntp inherits timezone {
+class ntp(
+ $servers = hiera('ntp::servers', '')
+) {
+ class { 'timezone': }
- case $ntp_servers {
- '': { fail("you need to define \$ntp_servers for ntp module") }
+ case $servers {
+ '': { fail("you need to define ntp::servers for ntp module") }
}
# the needed packages
@@ -54,12 +59,15 @@ class ntp inherits timezone {
}
-class ntpdate inherits timezone {
+class ntpdate(
+ $pool = hiera('ntp::pool', '')
+) {
+ class { 'timezone': }
# TODO: add logrotate rule to /var/log/ntpdate.log
- case $ntp_pool {
- '': { fail("you need to define \$ntp_pool for ntp module") }
+ case $pool {
+ '': { fail("you need to define ntp::pool for ntp module") }
}
# the needed packages
@@ -69,7 +77,7 @@ class ntpdate inherits timezone {
# adjust time using ntpdate
cron { "ntpdate":
- command => "/usr/sbin/ntpdate -t 5 ${ntp_pool} >> /var/log/ntpdate.log 2>&1",
+ command => "/usr/sbin/ntpdate -t 5 ${pool} >> /var/log/ntpdate.log 2>&1",
user => root,
hour => "*/1",
minute => "10",
diff --git a/templates/ntp.conf.erb b/templates/ntp.conf.erb
index 988f310..ae86940 100644
--- a/templates/ntp.conf.erb
+++ b/templates/ntp.conf.erb
@@ -9,7 +9,7 @@ filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# ntp servers
-<% ntp_servers.each do |server| -%>server <%= server => iburst<% end -%>
+<% servers.each do |server| -%>server <%= server => iburst<% end -%>
# configuracoes de restricao de acesso
# access restrictions