From: František Dvořák Date: Sat, 13 Dec 2014 14:19:12 +0000 (+0100) Subject: Class for configure automatic updates. Must be included explicitely. X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=a85d1f9405a9bbd769dc7466867cbe27982fc819;p=meta-site_hadoop.git Class for configure automatic updates. Must be included explicitely. --- diff --git a/doc/manifest.pp b/doc/manifest.pp new file mode 100644 index 0000000..2507d1a --- /dev/null +++ b/doc/manifest.pp @@ -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 index 0000000..56d0a8c --- /dev/null +++ b/files/cron-apt-upgrade @@ -0,0 +1 @@ +-q -q upgrade diff --git a/manifests/autoupdate.pp b/manifests/autoupdate.pp new file mode 100644 index 0000000..93faa17 --- /dev/null +++ b/manifests/autoupdate.pp @@ -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], + } + } +} diff --git a/manifests/init.pp b/manifests/init.pp index b24a989..5938d8a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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' diff --git a/manifests/params.pp b/manifests/params.pp index cc2fb9d..9eb84c6 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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 index 0000000..fcd29db --- /dev/null +++ b/templates/cron-apt.conf.erb @@ -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 index 0000000..daf0f90 --- /dev/null +++ b/templates/cron-apt.cron.erb @@ -0,0 +1 @@ +<%= @time -%> root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt