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