Puppet Class: autoupdate

Inherits:
::autoupdate::params
Defined in:
manifests/init.pp

Overview

Class: autoupdate

The main autoupdate class.

Parameters

####‘email` Email to sent notifications. Default is undef.

####‘randomwait` Random time to wait before update in seconds. Default is to leave it to the autoupdate tools (1 hour for cron-apt and yum-autoupdate).

####‘update` Update type. Default is ’default’.

  • cron-apt: default, dist

  • yum_autoupdate: default, security, minimal, …

Unknown types translates to default.

####‘hour` ####`minute` ####`month` ####`monthday` ####`weekday` ####`special` Parameters for cron job. Beware the defaults are *!

Parameters:

  • email (Any) (defaults to: undef)
  • randomwait (Any) (defaults to: undef)
  • update (Any) (defaults to: 'default')
  • hour (Any) (defaults to: 5)
  • minute (Any) (defaults to: absent)
  • month (Any) (defaults to: absent)
  • monthday (Any) (defaults to: absent)
  • weekday (Any) (defaults to: absent)
  • special (Any) (defaults to: absent)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'manifests/init.pp', line 29

class autoupdate(
  $email = undef,
  $randomwait = undef,
  $update = 'default',

  $hour = 5,
  $minute = absent,
  $month = absent,
  $monthday = absent,
  $weekday = absent,
  $special = absent,
) inherits ::autoupdate::params {
  include stdlib

  validate_string($update)

  case $::osfamily {
    'Debian': {
      $action = $update ? {
        /dist(-upgrade)?/ => 'dist-upgrade',
        default           => 'upgrade',
      }
      include autoupdate::cron_apt
    }
    'RedHat': {
      $action = $update ? {
        /dist(-upgrade)?/ => 'default',
        /upgrade/         => 'default',
        default           => $update,
      }
      $notify = $email ? {
        undef   => false,
        default => true,
      }
      case $randomwait {
        undef: {
          $randomwait_min = undef
        }
        default: {
          $randomwait_min = $randomwait / 60
        }
      }
      class{'yum_autoupdate':
        default_schedule => false,
      }
      yum_autoupdate::schedule { 'autoupdate':
        email_from   => "root@${::fqdn}",
        email_to     => $email,
        notify_email => $notify,
        update_cmd   => $action,
        randomwait   => $randomwait_min,
        hour         => $hour,
        minute       => $minute,
        month        => $month,
        monthday     => $monthday,
        weekday      => $weekday,
        special      => $special,
      }
    }
    default: {
      fail("${::osfamily}/${::operatingsystem} not supported")
    }
  }
}