diff options
Diffstat (limited to 'manifests/reboot_required_notify')
-rw-r--r-- | manifests/reboot_required_notify/jessie.pp | 28 | ||||
-rw-r--r-- | manifests/reboot_required_notify/wheezy.pp | 23 |
2 files changed, 51 insertions, 0 deletions
diff --git a/manifests/reboot_required_notify/jessie.pp b/manifests/reboot_required_notify/jessie.pp new file mode 100644 index 0000000..2de6b62 --- /dev/null +++ b/manifests/reboot_required_notify/jessie.pp @@ -0,0 +1,28 @@ +class apt::reboot_required_notify::jessie ($ensure = present) { + + if $::operatingsystemmajrelease == 8 and ! $::apt::use_backports { + fail('apt::reboot_required_notify requires $apt::use_backports on Jessie') + } + + $pinning_ensure = $::operatingsystemmajrelease ? { + 8 => present, + default => absent, + } + apt::preferences_snippet { 'reboot-notifier': + ensure => $pinning_ensure, + pin => 'release o=Debian Backports,a=jessie-backports', + priority => 991, + } + + # On Jessie and newer, this package installs the script that created + # /var/run/reboot-required*. + # This script (/usr/share/update-notifier/notify-reboot-required) is + # triggered e.g. by kernel packages. + # This package also sends a daily email to the administrator when a system + # reboot is required, e.g. due to a kernel update. + package { 'reboot-notifier': + ensure => $ensure, + require => Apt::Preferences_snippet['reboot-notifier'], + } + +} diff --git a/manifests/reboot_required_notify/wheezy.pp b/manifests/reboot_required_notify/wheezy.pp new file mode 100644 index 0000000..06998ef --- /dev/null +++ b/manifests/reboot_required_notify/wheezy.pp @@ -0,0 +1,23 @@ +class apt::reboot_required_notify::wheezy ($ensure = present) { + + # On Wheezy and older, this package installs the script that created + # /var/run/reboot-required*. + # This script (/usr/share/update-notifier/notify-reboot-required) is + # triggered e.g. by kernel packages. + package { 'update-notifier-common': + ensure => $ensure, + } + + # cron-apt defaults to run every night at 4 o'clock + # plus some random time <1h. + # so we check if a reboot is required a bit later. + cron { 'apt_reboot_required_notify': + ensure => $ensure, + command => 'if [ -f /var/run/reboot-required ]; then echo "Reboot required\n" ; cat /var/run/reboot-required.pkgs ; fi', + user => root, + hour => 5, + minute => 20, + require => Package['update-notifier-common'], + } + +} |