aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystem/apt.pp
blob: a93125e240c9fbf8a3d6205de437651578f746d8 (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
class nodo::subsystem::apt(
  $ensure       = present,
  $auto_upgrade = present,
  $hour         = 2,
  $minute       = 0,
) {
  file { '/etc/apt/sources.list':
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 0644,
    content => $ensure ? {
      'present' => template("nodo/apt/${::operatingsystem}.sources.list.erb"),
       default  => undef,
    },
  }

  # We have /var/log/dpkg.log, so we do not need to rotate /var/log/upgrade.log
  $log     = ">> /var/log/upgrade.log 2>&1"
  $apt     = '/usr/bin/apt-get'
  $command = "${apt} update ${log} && ${apt} dist-upgrade -y ${log} && ${apt} autoremove -y ${log} && ${apt} clean ${log}"

  cron { 'nodo-apt-auto-upgrade':
    ensure      => $auto_upgrade,
    command     => $command,
    environment => 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    user        => 'root',
    hour        => $hour,
    minute      => $minute,
  }
}