48b617e6e059bd5a5b8d22eeef09dbf439e713c5
[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         if has_role('experimental_apache') {
45                 $dbdosuites = [ 'debian-all', $::lsbdistcodename, 'jessie-apache2' ]
46         } else {
47                 $dbdosuites = [ 'debian-all', $::lsbdistcodename ]
48         }
49         site::aptrepo { 'db.debian.org':
50                 url        => 'http://db.debian.org/debian-admin',
51                 suite      => $dbdosuites,
52                 components => 'main',
53                 key        => 'puppet:///modules/debian_org/db.debian.org.gpg',
54         }
55
56         if ($::hostname in [] or $::debarchitecture in ['kfreebsd-amd64', 'kfreebsd-i386']) {
57                 site::aptrepo { 'proposed-updates':
58                         url        => $mirror,
59                         suite      => "${mungedcodename}-proposed-updates",
60                         components => ['main','contrib','non-free']
61                 }
62         } else {
63                 site::aptrepo { 'proposed-updates':
64                         ensure => absent,
65                 }
66         }
67
68         site::aptrepo { 'debian-cdn':
69                 ensure => absent,
70         }
71         site::aptrepo { 'debian.org':
72                 ensure => absent,
73         }
74         site::aptrepo { 'debian2':
75                 ensure => absent,
76         }
77         site::aptrepo { 'backports2.debian.org':
78                 ensure => absent,
79         }
80         site::aptrepo { 'backports.debian.org':
81                 ensure => absent,
82         }
83         site::aptrepo { 'volatile':
84                 ensure => absent,
85         }
86         site::aptrepo { 'db.debian.org-suite':
87                 ensure => absent,
88         }
89         site::aptrepo { 'debian-lts':
90                 ensure => absent,
91         }
92
93
94
95
96         file { '/etc/apt/trusted-keys.d':
97                 ensure => absent,
98                 force  => true,
99         }
100
101         file { '/etc/apt/trusted.gpg':
102                 mode    => '0600',
103                 content => "",
104         }
105
106         file { '/etc/apt/preferences':
107                 source => 'puppet:///modules/debian_org/apt.preferences',
108         }
109         file { '/etc/apt/apt.conf.d/local-compression':
110                 source => 'puppet:///modules/debian_org/apt.conf.d/local-compression',
111         }
112         file { '/etc/apt/apt.conf.d/local-recommends':
113                 source => 'puppet:///modules/debian_org/apt.conf.d/local-recommends',
114         }
115         file { '/etc/apt/apt.conf.d/local-pdiffs':
116                 source => 'puppet:///modules/debian_org/apt.conf.d/local-pdiffs',
117         }
118         file { '/etc/apt/apt.conf.d/local-langs':
119                 source => 'puppet:///modules/debian_org/apt.conf.d/local-langs',
120         }
121
122         exec { 'apt-get update':
123                 path    => '/usr/bin:/usr/sbin:/bin:/sbin',
124                 onlyif  => '/usr/local/bin/check_for_updates',
125                 require => File['/usr/local/bin/check_for_updates']
126         }
127         Exec['apt-get update']->Package<| tag == extra_repo |>
128 }