puppet 4 foo
[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 $::lsbmajdistrelease <= '7' {
7                 $mungedcodename = $::lsbdistcodename
8         } elsif ($::debarchitecture in ['kfreebsd-amd64', 'kfreebsd-i386']) {
9                 $mungedcodename = "${::lsbdistcodename}-kfreebsd"
10         } else {
11                 $mungedcodename = $::lsbdistcodename
12         }
13
14         if $::lsbmajdistrelease <= '8' {
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         site::aptrepo { 'security':
32                 url        => [ 'http://security-cdn.debian.org/', 'http://security.anycast-test.mirrors.debian.org/debian-security/', 'http://security.debian.org/' ],
33                 suite      => "${mungedcodename}/updates",
34                 components => ['main','contrib','non-free']
35         }
36
37         if has_role('experimental_apache') {
38                 $dbdosuites = [ 'debian-all', $::lsbdistcodename, 'jessie-apache2' ]
39         } else {
40                 $dbdosuites = [ 'debian-all', $::lsbdistcodename ]
41         }
42         site::aptrepo { 'db.debian.org':
43                 url        => 'http://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 [] or $::debarchitecture in ['kfreebsd-amd64', 'kfreebsd-i386']) {
50                 site::aptrepo { 'proposed-updates':
51                         url        => $mirror,
52                         suite      => "${mungedcodename}-proposed-updates",
53                         components => ['main','contrib','non-free']
54                 }
55         } else {
56                 site::aptrepo { 'proposed-updates':
57                         ensure => absent,
58                 }
59         }
60
61         site::aptrepo { 'debian-cdn':
62                 ensure => absent,
63         }
64         site::aptrepo { 'debian.org':
65                 ensure => absent,
66         }
67         site::aptrepo { 'debian2':
68                 ensure => absent,
69         }
70         site::aptrepo { 'backports2.debian.org':
71                 ensure => absent,
72         }
73         site::aptrepo { 'backports.debian.org':
74                 ensure => absent,
75         }
76         site::aptrepo { 'volatile':
77                 ensure => absent,
78         }
79         site::aptrepo { 'db.debian.org-suite':
80                 ensure => absent,
81         }
82         site::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
115         exec { 'apt-get update':
116                 path    => '/usr/bin:/usr/sbin:/bin:/sbin',
117                 onlyif  => '/usr/local/bin/check_for_updates',
118                 require => File['/usr/local/bin/check_for_updates']
119         }
120         Exec['apt-get update']->Package<| tag == extra_repo |>
121 }