703cafc42efa38062ef8baa3e3cf90912068f85e
[mirror/dsa-puppet.git] / modules / debian_org / manifests / apt.pp
1 # == Class: debian_org
2 #
3 # Stuff common to all debian.org servers
4 #
5 class debian_org::apt {
6         if versioncmp($::lsbmajdistrelease, '8') <= 0 {
7                 $fallbackmirror = 'http://cdn-fastly.deb.debian.org/debian/'
8         } else {
9                 $fallbackmirror = 'http://deb.debian.org/debian/'
10         }
11
12         if getfromhash($site::nodeinfo, 'hoster', 'mirror-debian') {
13                 $mirror = [ getfromhash($site::nodeinfo, 'hoster', 'mirror-debian'), $fallbackmirror ]
14         } else {
15                 $mirror = [ $fallbackmirror ]
16         }
17
18         site::aptrepo { 'debian':
19                 url        => $mirror,
20                 suite      => [ $::lsbdistcodename, "${::lsbdistcodename}-backports", "${::lsbdistcodename}-updates" ],
21                 components => ['main','contrib','non-free']
22         }
23
24         if ($::hostname in [smetana]) {
25                 site::aptrepo { 'security':
26                         ensure => absent,
27                 }
28         } elsif versioncmp($::lsbmajdistrelease, '8') <= 0 {
29                 site::aptrepo { 'security':
30                         url        => [ 'http://security-cdn.debian.org/', 'http://security.debian.org/' ],
31                         suite      => "${::lsbdistcodename}/updates",
32                         components => ['main','contrib','non-free']
33                 }
34         } else {
35                 site::aptrepo { 'security':
36                         url        => [ 'http://security.debian.org/' ],
37                         suite      => "${::lsbdistcodename}/updates",
38                         components => ['main','contrib','non-free']
39                 }
40         }
41
42         $dbdosuites = [ 'debian-all', $::lsbdistcodename ]
43         site::aptrepo { 'db.debian.org':
44                 url        => 'http://db.debian.org/debian-admin',
45                 suite      => $dbdosuites,
46                 components => 'main',
47                 key        => 'puppet:///modules/debian_org/db.debian.org.gpg',
48         }
49
50         if ($::hostname in []) {
51                 site::aptrepo { 'proposed-updates':
52                         url        => $mirror,
53                         suite      => "${::lsbdistcodename}-proposed-updates",
54                         components => ['main','contrib','non-free']
55                 }
56         } else {
57                 site::aptrepo { 'proposed-updates':
58                         ensure => absent,
59                 }
60         }
61
62         site::aptrepo { 'debian-cdn':
63                 ensure => absent,
64         }
65         site::aptrepo { 'debian.org':
66                 ensure => absent,
67         }
68         site::aptrepo { 'debian2':
69                 ensure => absent,
70         }
71         site::aptrepo { 'backports2.debian.org':
72                 ensure => absent,
73         }
74         site::aptrepo { 'backports.debian.org':
75                 ensure => absent,
76         }
77         site::aptrepo { 'volatile':
78                 ensure => absent,
79         }
80         site::aptrepo { 'db.debian.org-suite':
81                 ensure => absent,
82         }
83         site::aptrepo { 'debian-lts':
84                 ensure => absent,
85         }
86
87
88
89
90         file { '/etc/apt/trusted-keys.d':
91                 ensure => absent,
92                 force  => true,
93         }
94
95         file { '/etc/apt/trusted.gpg':
96                 mode    => '0600',
97                 content => "",
98         }
99
100         file { '/etc/apt/preferences':
101                 source => 'puppet:///modules/debian_org/apt.preferences',
102         }
103         file { '/etc/apt/apt.conf.d/local-compression':
104                 source => 'puppet:///modules/debian_org/apt.conf.d/local-compression',
105         }
106         file { '/etc/apt/apt.conf.d/local-recommends':
107                 source => 'puppet:///modules/debian_org/apt.conf.d/local-recommends',
108         }
109         file { '/etc/apt/apt.conf.d/local-pdiffs':
110                 source => 'puppet:///modules/debian_org/apt.conf.d/local-pdiffs',
111         }
112         file { '/etc/apt/apt.conf.d/local-langs':
113                 source => 'puppet:///modules/debian_org/apt.conf.d/local-langs',
114         }
115
116         exec { 'apt-get update':
117                 path    => '/usr/bin:/usr/sbin:/bin:/sbin',
118                 onlyif  => '/usr/local/bin/check_for_updates',
119                 require => File['/usr/local/bin/check_for_updates']
120         }
121         Exec['apt-get update']->Package<| tag == extra_repo |>
122 }