eaed3f1331c6485856d0cbb4891bcf182ec56afe
[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         $mirror = lookup('apt::sources::debian::location')
7
8         # jessie
9         if versioncmp($::lsbmajdistrelease, '8') <= 0 {
10                 base::aptrepo { 'debian':
11                         url        => $mirror,
12                         suite      => [ $::lsbdistcodename ],
13                         components => ['main','contrib','non-free']
14                 }
15         # stretch or buster
16         } else {
17                 base::aptrepo { 'debian':
18                         url        => $mirror,
19                         suite      => [ $::lsbdistcodename, "${::lsbdistcodename}-backports", "${::lsbdistcodename}-updates" ],
20                         components => ['main','contrib','non-free']
21                 }
22         }
23
24         base::aptrepo { 'security':
25                 url        => [ 'http://security.debian.org/' ],
26                 suite      => "${::lsbdistcodename}/updates",
27                 components => ['main','contrib','non-free']
28         }
29
30         # ca-certificates is installed by the ssl module
31         if versioncmp($::lsbmajdistrelease, '9') <= 0 {
32                 package { 'apt-transport-https':
33                         ensure => installed,
34                 }
35         } else {
36                 # transitional package in buster
37                 package { 'apt-transport-https':
38                         ensure => purged,
39                 }
40         }
41         $dbdosuites = [ 'debian-all', $::lsbdistcodename ]
42         base::aptrepo { 'db.debian.org':
43                 url        => 'https://db.debian.org/debian-admin',
44                 suite      => $dbdosuites,
45                 components => 'main',
46                 key        => 'puppet:///modules/debian_org/db.debian.org.gpg',
47         }
48
49         if ($::hostname in []) {
50                 base::aptrepo { 'proposed-updates':
51                         url        => $mirror,
52                         suite      => "${::lsbdistcodename}-proposed-updates",
53                         components => ['main','contrib','non-free']
54                 }
55         } else {
56                 base::aptrepo { 'proposed-updates':
57                         ensure => absent,
58                 }
59         }
60
61         base::aptrepo { 'debian-cdn':
62                 ensure => absent,
63         }
64         base::aptrepo { 'debian.org':
65                 ensure => absent,
66         }
67         base::aptrepo { 'debian2':
68                 ensure => absent,
69         }
70         base::aptrepo { 'backports2.debian.org':
71                 ensure => absent,
72         }
73         base::aptrepo { 'backports.debian.org':
74                 ensure => absent,
75         }
76         base::aptrepo { 'volatile':
77                 ensure => absent,
78         }
79         base::aptrepo { 'db.debian.org-suite':
80                 ensure => absent,
81         }
82         base::aptrepo { 'debian-lts':
83                 ensure => absent,
84         }
85
86
87
88
89         file { '/etc/apt/trusted-keys.d':
90                 ensure => absent,
91                 force  => true,
92         }
93
94         file { '/etc/apt/trusted.gpg':
95                 mode    => '0600',
96                 content => "",
97         }
98
99         file { '/etc/apt/preferences':
100                 source => 'puppet:///modules/debian_org/apt.preferences',
101         }
102         file { '/etc/apt/apt.conf.d/local-compression':
103                 source => 'puppet:///modules/debian_org/apt.conf.d/local-compression',
104         }
105         file { '/etc/apt/apt.conf.d/local-recommends':
106                 source => 'puppet:///modules/debian_org/apt.conf.d/local-recommends',
107         }
108         file { '/etc/apt/apt.conf.d/local-pdiffs':
109                 source => 'puppet:///modules/debian_org/apt.conf.d/local-pdiffs',
110         }
111         file { '/etc/apt/apt.conf.d/local-langs':
112                 source => 'puppet:///modules/debian_org/apt.conf.d/local-langs',
113         }
114         file { '/etc/apt/apt.conf.d/local-cainfo':
115                 source => 'puppet:///modules/debian_org/apt.conf.d/local-cainfo',
116         }
117         file { '/etc/apt/apt.conf.d/local-pkglist':
118                 source => 'puppet:///modules/debian_org/apt.conf.d/local-pkglist',
119         }
120
121         exec { 'dpkg list':
122                 command => 'dpkg-query -W -f \'${Package}\n\' > /var/lib/misc/thishost/pkglist',
123                 creates => '/var/lib/misc/thishost/pkglist',
124         }
125
126         exec { 'apt-get update':
127                 path    => '/usr/bin:/usr/sbin:/bin:/sbin',
128                 onlyif  => '/usr/local/bin/check_for_updates',
129                 require => File['/usr/local/bin/check_for_updates']
130         }
131         Exec['apt-get update']->Package<| tag == extra_repo |>
132 }