unattended_upgrades: Allow changing legacy_origin
[puppet-modules/puppetlabs-apt.git] / manifests / unattended_upgrades.pp
1 # Class: apt::unattended_upgrades
2 #
3 # This class manages the unattended-upgrades package and related configuration
4 # files for ubuntu
5 #
6 # origins are the repositories to automatically upgrade included packages
7 # blacklist is a list of packages to not automatically upgrade
8 # update is how often to run "apt-get update" in days
9 # download is how often to run "apt-get upgrade --download-only" in days
10 # upgrade is how often to upgrade packages included in the origins list in days
11 # autoclean is how often to run "apt-get autoclean" in days
12 #
13 # information on the other options can be found in the 50unattended-upgrades
14 # file and in /etc/cron.daily/apt
15 #
16 class apt::unattended_upgrades (
17   $legacy_origin       = $::apt::params::legacy_origin,
18   $origins             = $::apt::params::origins,
19   $blacklist           = [],
20   $update              = '1',
21   $download            = '1',
22   $upgrade             = '1',
23   $autoclean           = '7',
24   $auto_fix            = true,
25   $minimal_steps       = false,
26   $install_on_shutdown = false,
27   $mail_to             = 'NONE',
28   $mail_only_on_error  = false,
29   $remove_unused       = true,
30   $auto_reboot         = false,
31   $dl_limit            = 'NONE',
32   $randomsleep         = undef,
33   $enable              = '1',
34   $backup_interval     = '0',
35   $backup_level        = '3',
36   $max_age             = '0',
37   $min_age             = '0',
38   $max_size            = '0',
39   $download_delta      = '0',
40   $verbose             = '0',
41 ) inherits ::apt::params {
42
43   validate_bool(
44     $legacy_origin,
45     $auto_fix,
46     $minimal_steps,
47     $install_on_shutdown,
48     $mail_only_on_error,
49     $remove_unused,
50     $auto_reboot
51   )
52   validate_array($origins)
53
54   if $randomsleep {
55     unless is_numeric($randomsleep) {
56       fail('randomsleep must be numeric')
57     }
58   }
59
60   package { 'unattended-upgrades':
61     ensure => present,
62   }
63
64   file { '/etc/apt/apt.conf.d/50unattended-upgrades':
65     ensure  => file,
66     owner   => 'root',
67     group   => 'root',
68     mode    => '0644',
69     content => template('apt/_header.erb', 'apt/50unattended-upgrades.erb'),
70     require => Package['unattended-upgrades'],
71   }
72
73   file { '/etc/apt/apt.conf.d/10periodic':
74     ensure  => file,
75     owner   => 'root',
76     group   => 'root',
77     mode    => '0644',
78     content => template('apt/_header.erb', 'apt/10periodic.erb'),
79     require => Package['unattended-upgrades'],
80   }
81 }