summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 7b09d0a5b987e5e4e9aa00575d4ba24dbe241889 (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
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 {

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

  validate_bool(
    $install_on_shutdown,
    $legacy_origin,
    $minimal_steps,
  )
  validate_array($blacklist)
  validate_array($origins)
  validate_hash($auto)
  $_auto = merge($::unattended_upgrades::default_auto, $auto)
  validate_hash($mail)
  if $mail['only_on_error'] {
    validate_bool($mail['only_on_error'])
  }
  $_mail = merge($::unattended_upgrades::default_mail, $mail)
  validate_hash($backup)
  $_backup = merge($::unattended_upgrades::default_backup, $backup)
  validate_hash($age)
  $_age = merge($::unattended_upgrades::default_age, $age)
  validate_integer($size)
  validate_hash($upgradeable_packages)
  $_upgradeable_packages = merge($::unattended_upgrades::default_upgradeable_packages, $upgradeable_packages)
  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,
  }

}