diff options
author | Jerome Charaoui <jcharaoui@cmaisonneuve.qc.ca> | 2016-06-29 19:47:42 +0000 |
---|---|---|
committer | Jerome Charaoui <jcharaoui@cmaisonneuve.qc.ca> | 2016-06-29 19:47:42 +0000 |
commit | 1a87e2f7d489fe01e84e2fad6d368dbbc52f1995 (patch) | |
tree | 3acffc72619666af44d1a846f9ad4b24258abd8a /manifests | |
parent | 6277c3ba14d85b0c5d0d8cad3fc25dc9aa206357 (diff) | |
parent | 70118955f6dae59a021880865408cf9367c3dc57 (diff) |
Merge branch 'bugfix/reboot-required-jessie' into 'master'
Bugfix/reboot required jessie
I've mistakenly marked !40 as merged :/
See merge request !46
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/reboot_required_notify.pp | 22 | ||||
-rw-r--r-- | manifests/reboot_required_notify/jessie.pp | 28 | ||||
-rw-r--r-- | manifests/reboot_required_notify/wheezy.pp | 23 |
3 files changed, 57 insertions, 16 deletions
diff --git a/manifests/reboot_required_notify.pp b/manifests/reboot_required_notify.pp index 722e8a5..efd8aeb 100644 --- a/manifests/reboot_required_notify.pp +++ b/manifests/reboot_required_notify.pp @@ -1,21 +1,11 @@ class apt::reboot_required_notify { - # 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 => installed, - } - - # 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': - 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'], + if versioncmp($::operatingsystemmajrelease, 8) >= 0 { + class { 'apt::reboot_required_notify::jessie': } + # Clean up systems that were upgraded from Wheezy or earlier: + class { 'apt::reboot_required_notify::wheezy': ensure => absent } + } else { + class { 'apt::reboot_required_notify::wheezy': } } } 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'], + } + +} |