summaryrefslogtreecommitdiff
path: root/manifests/unattended_upgrades.pp
blob: 85d21d411ee4bc3d0418c1edc2cb4e88ae24551e (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
class apt::unattended_upgrades (
  $config_content       = undef,
  $config_template      = 'apt/50unattended-upgrades.erb',
  $mailonlyonerror      = true,
  $mail_recipient       = 'root',
  $blacklisted_packages = [],
  $ensure_version       = 'present',
) {

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

  # For some reason, this directory is sometimes absent, which causes
  # unattended-upgrades to crash.
  file { '/var/log/unattended-upgrades':
    ensure  => directory,
    owner   => 'root',
    group   => 0,
    mode    => '0755',
    require => Package['unattended-upgrades'],
  }

  $file_content = $config_content ? {
    undef   => template($config_template),
    default => $config_content
  }

  ::apt::apt_conf { '50unattended-upgrades':
    content     => $file_content,
    require     => Package['unattended-upgrades'],
    refresh_apt => false
  }
}