Puppet Class: r_profile::linux::apt

Defined in:
manifests/linux/apt.pp

Overview

R_profile::Linux::Apt

Setup of apt package manager

Parameters:

  • include_src (Any) (defaults to: true)
  • auto_update (Any) (defaults to: true)
  • update_hour (Any) (defaults to: fqdn_rand(23))
  • update_minute (Any) (defaults to: fqdn_rand(59))
  • update_month (Any) (defaults to: "*")
  • update_monthday (Any) (defaults to: "*")
  • update_weekday (Any) (defaults to: "*")


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
# File 'manifests/linux/apt.pp', line 4

class r_profile::linux::apt(
    $include_src      = true,
    $auto_update      = true,
    $update_hour      = fqdn_rand(23),
    $update_minute    = fqdn_rand(59),
    $update_month     = "*",
    $update_monthday  = "*",
    $update_weekday   = "*",
) {
  class { "apt":
    purge  =>  {
      "sources.list"  => true,
    },
    update => {
      frequency       => 'daily',
    },
  }

  # only for ubuntu with lsb-release package installed...
  if $lsbdistcodename {
    case $operatingsystem {
      "Ubuntu": {
        $releases          = [
          $lsbdistcodename,
          "${::lsbdistcodename}-updates",
          "${::lsbdistcodename}-security",
        ]
        $repos             = "main restricted universe multiverse"
        $security_repos    = $repos
        $default_location  = "http://archive.ubuntu.com/ubuntu/"
        $security_location = "http://security.ubuntu.com/ubuntu/"
        $security_release  = "${::lsbdistcodename}-security"
      }
      "Debian": {
        $releases          = [
          $lsdbdistcodename,
          "${::lsbdistcodename}-updates",
          "${::lsbdistcodename}-backports",
        ]
        $repos             = "main" # removed non-free
        $security_repos    = "main"
        $default_location  = "http://ftp.debian.org/debian/"
        $security_location = "http://security.debian.org/"
        $security_release  = "${::lsbdistcodename}/updates"
      }
      default: {
        fail("Class ${name} does not support ${operatingsystem}")
      }
    }

    $os = downcase($operatingsystem)
    $location = hiera(
      "r_profile::apt::${os}::location",
      $default_location
    )

    # regular updates for each release
    $releases.each | $release | {
      apt::source { "apt_archive_${::lsbdistcodename}-${release}":
        location    => $location,
        release     => $release,
        repos       => $repos,
        include_src => $include_src,
      }
    }

    # security updates - always from main servers
    apt::source { "apt_security":
      location    => $security_location,
      release     => $security_release,
      repos       => $security_repos,
      include_src => $include_src,
    }
  }

  if $auto_update {
    cron { "apt_auto_update":
      ensure      => present,
      command     => "apt-get update && apt-get upgrade -y",
      user        => "root",
      environment => "PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin",
      hour        => $update_hour,
      minute      => $update_minute,
      month       => $update_month,
      monthday    => $update_monthday,
      weekday     => $update_weekday,
    }
  }

}