Class for configure automatic updates. Must be included explicitely.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Sat, 13 Dec 2014 14:19:12 +0000 (15:19 +0100)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Sat, 13 Dec 2014 14:19:12 +0000 (15:19 +0100)
doc/manifest.pp [new file with mode: 0644]
files/cron-apt-upgrade [new file with mode: 0644]
manifests/autoupdate.pp [new file with mode: 0644]
manifests/init.pp
manifests/params.pp
templates/cron-apt.conf.erb [new file with mode: 0644]
templates/cron-apt.cron.erb [new file with mode: 0644]

diff --git a/doc/manifest.pp b/doc/manifest.pp
new file mode 100644 (file)
index 0000000..2507d1a
--- /dev/null
@@ -0,0 +1,7 @@
+include site_hadoop
+
+# if to enable autoupdates
+class{'site_hadoop::autoupdate':
+  email => 'email@example.com',
+  time => '0 5 * * *',
+}
diff --git a/files/cron-apt-upgrade b/files/cron-apt-upgrade
new file mode 100644 (file)
index 0000000..56d0a8c
--- /dev/null
@@ -0,0 +1 @@
+-q -q upgrade
diff --git a/manifests/autoupdate.pp b/manifests/autoupdate.pp
new file mode 100644 (file)
index 0000000..93faa17
--- /dev/null
@@ -0,0 +1,32 @@
+# == Class site_hadoop::autoupdate
+#
+# Configure automatic updates on Debian.
+#
+# === Parameters
+#
+# [*email*] undef
+#   If specified, sent email on upgrade.
+#
+class site_hadoop::autoupdate(
+  $email = undef,
+  $time = $site_hadoop::params::time_autoupdate,
+) inherits site_hadoop::params {
+  include stdlib
+
+  ensure_packages($site_hadoop::params::packages_autoupdate)
+
+  if $::osfamily == 'Debian' {
+    file { '/etc/cron-apt/config':
+      content => template('site_hadoop/cron-apt.conf.erb'),
+      require => Package[$site_hadoop::params::packages_autoupdate],
+    }
+    file { '/etc/cron-apt/action.d/9-upgrade':
+      source  => 'puppet:///modules/site_hadoop/cron-apt-upgrade',
+      require => Package[$site_hadoop::params::packages_autoupdate],
+    }
+    file { '/etc/cron.d/cron-apt':
+      content => template('site_hadoop/cron-apt.cron.erb'),
+      require => Package[$site_hadoop::params::packages_autoupdate],
+    }
+  }
+}
index b24a989..5938d8a 100644 (file)
@@ -1,3 +1,7 @@
+# == Class site_hadoop
+#
+# Basic system configurations for Hadoop cluster on Meta.
+#
 class site_hadoop inherits site_hadoop::params {
   include 'site_hadoop::install'
   include 'site_hadoop::config'
index cc2fb9d..9eb84c6 100644 (file)
@@ -20,5 +20,13 @@ class site_hadoop::params {
     debian => '/usr/lib/mc/mc',
   }
 
+  $packages_autoupdate = $::osfamily ? {
+    debian => ['cron-apt'],
+    redhat => ['yum-autoupdate'],
+  }
+
+  # every night at 5:00
+  $time_autoupdate = '0 5 * * *'
+
   $path = '/sbin:/usr/sbin:/bin:/usr/bin'
 }
diff --git a/templates/cron-apt.conf.erb b/templates/cron-apt.conf.erb
new file mode 100644 (file)
index 0000000..fcd29db
--- /dev/null
@@ -0,0 +1,4 @@
+<% if @email -%>
+MAILTO=<%= @email %>
+MAILON=upgrade
+<% end -%>
diff --git a/templates/cron-apt.cron.erb b/templates/cron-apt.cron.erb
new file mode 100644 (file)
index 0000000..daf0f90
--- /dev/null
@@ -0,0 +1 @@
+<%= @time -%>  root    test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt