Merge remote-tracking branch 'shared/master' into drop_lenny_squeeze_support
This commit is contained in:
commit
a18c940b01
8 changed files with 96 additions and 83 deletions
33
README.md
33
README.md
|
@ -8,7 +8,6 @@
|
|||
* [Classes](#classes)
|
||||
* [apt](#apt)
|
||||
* [apt::apticron](#apt-apticron)
|
||||
* [apt::cron::download](#apt-cron-download)
|
||||
* [apt::cron::dist_upgrade](#apt-cron-dist_upgrade)
|
||||
* [apt::dist_upgrade](#apt-dist_upgrade)
|
||||
* [apt::dist_upgrade::initiator](#apt-dist_upgrade-initiator)
|
||||
|
@ -50,6 +49,9 @@ Ubuntu support is lagging behind but not absent either.
|
|||
|
||||
## Upgrade Notice<a name="upgrade-notice"></a>
|
||||
|
||||
* The `$apt_cron_hours` global variable is deprecated.
|
||||
Use `apt::cron::dist_upgrade`'s `cron_hours` parameter instead.
|
||||
|
||||
* The default value of the `$repos` parameter was removed since the logic is
|
||||
now in the `apt::params` class. If you have explicitly set `$repos` to
|
||||
'auto' in your manifests, you should remove this.
|
||||
|
@ -321,29 +323,19 @@ Example usage:
|
|||
}
|
||||
|
||||
|
||||
## apt::cron::download<a name="apt-cron-download"></a>
|
||||
|
||||
This class sets up `cron-apt` so that it downloads upgradable packages, does not
|
||||
actually do any upgrade and emails when the output changes.
|
||||
|
||||
`cron-apt` defaults to run at 4 AM. You may want to set the
|
||||
`$apt_cron_hours` variable before you include the class: its value will
|
||||
be passed as the "hours" parameter of a cronjob. Example:
|
||||
|
||||
# Run cron-apt every three hours
|
||||
$apt_cron_hours = '*/3'
|
||||
|
||||
Note that the default 4 AM cronjob won't be disabled.
|
||||
|
||||
|
||||
## apt::cron::dist_upgrade<a name="apt-cron-dist_upgrade"></a>
|
||||
|
||||
This class sets up cron-apt so that it dist-upgrades the system and
|
||||
emails when upgrades are performed.
|
||||
|
||||
See [apt::cron::download](#apt-cron-download) above if you need to run `cron-apt` more often
|
||||
than once a day.
|
||||
`cron-apt` defaults to run at 4 AM. You may want to set the
|
||||
`$cron_hours` class parameter before you include the class: its value will
|
||||
be passed as the "hours" parameter of a cronjob. Example:
|
||||
|
||||
# Run cron-apt every three hours
|
||||
class { 'apt::cron::dist_upgrade': cron_hours => '*/3' }
|
||||
|
||||
Note that the default 4 AM cronjob won't be disabled.
|
||||
|
||||
## apt::dist_upgrade<a name="apt-dist_upgrade"></a>
|
||||
|
||||
|
@ -356,6 +348,11 @@ classes may inherit from this one and add to its subscription list
|
|||
using the plusignment (`+>`) operator. A real-world example can be
|
||||
seen in the `apt::dist_upgrade::initiator` source.
|
||||
|
||||
Parameters:
|
||||
|
||||
* timeout: specified in seconds; the maximum time the `dist-upgrade`
|
||||
command should take. If the command takes longer than the timeout,
|
||||
the command is considered to have failed and will be stopped.
|
||||
|
||||
## apt::dist_upgrade::initiator<a name="apt-dist_upgrade-initiator"></a>
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
class apt::cron::base {
|
||||
|
||||
package { 'cron-apt': ensure => installed }
|
||||
|
||||
case $apt_cron_hours {
|
||||
'': {}
|
||||
default: {
|
||||
# cron-apt defaults to run every night at 4 o'clock
|
||||
# so we try not to run at the same time.
|
||||
cron { 'apt_cron_every_N_hours':
|
||||
command => 'test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt',
|
||||
user => root,
|
||||
hour => "${apt_cron_hours}",
|
||||
minute => 10,
|
||||
require => Package['cron-apt'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,23 @@
|
|||
class apt::cron::dist_upgrade inherits apt::cron::base {
|
||||
class apt::cron::dist_upgrade (
|
||||
$cron_hours = '',
|
||||
) {
|
||||
|
||||
package { 'cron-apt': ensure => installed }
|
||||
|
||||
case $cron_hours {
|
||||
'': {}
|
||||
default: {
|
||||
# cron-apt defaults to run every night at 4 o'clock
|
||||
# so we try not to run at the same time.
|
||||
cron { 'apt_cron_every_N_hours':
|
||||
command => 'test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt',
|
||||
user => root,
|
||||
hour => "${cron_hours}",
|
||||
minute => 10,
|
||||
require => Package['cron-apt'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$action = "autoclean -y
|
||||
dist-upgrade -y -o APT::Get::Show-Upgraded=true -o 'DPkg::Options::=--force-confold'
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
class apt::cron::download inherits apt::cron::base {
|
||||
|
||||
$action = "autoclean -y
|
||||
dist-upgrade -d -y -o APT::Get::Show-Upgraded=true
|
||||
"
|
||||
|
||||
file { '/etc/cron-apt/action.d/4-dist-upgrade':
|
||||
ensure => absent,
|
||||
}
|
||||
|
||||
file { '/etc/cron-apt/action.d/3-download':
|
||||
content => $action,
|
||||
require => Package[cron-apt],
|
||||
owner => root,
|
||||
group => 0,
|
||||
mode => '0644';
|
||||
}
|
||||
|
||||
file { '/etc/cron-apt/config.d/MAILON':
|
||||
content => "MAILON=changes\n",
|
||||
require => Package[cron-apt],
|
||||
owner => root,
|
||||
group => 0,
|
||||
mode => '0644';
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
class apt::dist_upgrade {
|
||||
class apt::dist_upgrade (
|
||||
$timeout = 300,
|
||||
) {
|
||||
|
||||
exec { 'apt_dist-upgrade':
|
||||
command => '/usr/bin/apt-get -q -y -o \'DPkg::Options::=--force-confold\' dist-upgrade',
|
||||
refreshonly => true,
|
||||
timeout => $timeout,
|
||||
before => Exec['apt_updated']
|
||||
}
|
||||
|
||||
|
|
|
@ -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': }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
28
manifests/reboot_required_notify/jessie.pp
Normal file
28
manifests/reboot_required_notify/jessie.pp
Normal file
|
@ -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'],
|
||||
}
|
||||
|
||||
}
|
23
manifests/reboot_required_notify/wheezy.pp
Normal file
23
manifests/reboot_required_notify/wheezy.pp
Normal file
|
@ -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'],
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue