summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 613f0ba24e0bc669a019d07752ab20750bcfdce5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
class unattended_upgrades (
  $age                  = {},
  $auto                 = {},
  $backup               = {},
  $blacklist            = [],
  $dl_limit             = undef,
  $enable               = 1,
  $install_on_shutdown  = false,
  $legacy_origin        = $::unattended_upgrades::params::legacy_origin,
  $mail                 = {},
  $minimal_steps        = true,
  $origins              = $::unattended_upgrades::params::origins,
  $package_ensure       = installed,
  $random_sleep         = undef,
  $size                 = 0,
  $update               = 1,
  $upgrade              = 1,
  $upgradeable_packages = {},
  $verbose              = 0,
  $notify_update        = false,
  $options              = {},
) inherits ::unattended_upgrades::params {

  validate_hash($age)
  $_age = merge($::unattended_upgrades::default_age, $age)
  validate_integer($_age['min'], undef, 0)
  validate_integer($_age['max'], undef, 0)

  validate_hash($auto)
  $_auto = merge($::unattended_upgrades::default_auto, $auto)
  validate_integer($_auto['clean'], undef, 0)
  validate_bool($_auto['fix_interrupted_dpkg'])
  validate_bool($_auto['reboot'])
  validate_string($_auto['reboot_time'])
  validate_bool($_auto['remove'])

  validate_hash($backup)
  $_backup = merge($::unattended_upgrades::default_backup, $backup)
  validate_integer($_backup['archive_interval'], undef, 0)
  validate_integer($_backup['level'], undef, 0)

  validate_array($blacklist)

  if $dl_limit != undef {
    validate_integer($dl_limit, undef, 0)
  }

  validate_integer($enable, 1, 0)

  validate_bool($install_on_shutdown)

  validate_bool($legacy_origin)
  validate_array($origins)
  if $legacy_origin == undef or $origins == undef {
    fail('Please explicitly specify unattended_upgrades::legacy_origin and unattended_upgrades::origins.')
  }

  validate_hash($mail)
  $_mail = merge($::unattended_upgrades::default_mail, $mail)
  validate_bool($_mail['only_on_error'])

  validate_bool($minimal_steps)

  validate_string($package_ensure)

  if $random_sleep != undef {
    validate_integer($random_sleep, undef, 0)
  }

  validate_integer($size, undef, 0)

  validate_integer($update, undef, 0)

  validate_integer($upgrade, undef, 0)

  validate_hash($upgradeable_packages)
  $_upgradeable_packages = merge($::unattended_upgrades::default_upgradeable_packages, $upgradeable_packages)
  validate_integer($_upgradeable_packages['download_only'], undef, 0)
  validate_integer($_upgradeable_packages['debdelta'], undef, 0)

  validate_integer($verbose, undef, 0)

  validate_bool($notify_update)

  validate_hash($options)
  $_options = merge($unattended_upgrades::default_options, $options)
  validate_bool($_options['force_confdef'])
  validate_bool($_options['force_confold'])
  validate_bool($_options['force_confnew'])
  validate_bool($_options['force_confmiss'])

  package { 'unattended-upgrades':
    ensure => $package_ensure,
  }

  apt::conf { 'unattended-upgrades':
    priority      => 50,
    content       => template("${module_name}/unattended-upgrades.erb"),
    require       => Package['unattended-upgrades'],
    notify_update => $notify_update,
  }

  apt::conf { 'periodic':
    priority      => 10,
    content       => template("${module_name}/periodic.erb"),
    require       => Package['unattended-upgrades'],
    notify_update => $notify_update,
  }

  apt::conf { 'auto-upgrades':
    ensure        => absent,
    priority      => 20,
    require       => Package['unattended-upgrades'],
    notify_update => $notify_update,
  }
  apt::conf { 'options':
    priority      => 10,
    content       => template("${module_name}/options.erb"),
    require       => Package['unattended-upgrades'],
    notify_update => $notify_update,
  }

}