Use deb.debian.org as the default mirror to test it
[mirror/dsa-puppet.git] / modules / debian-org / manifests / init.pp
1 # == Class: debian-org
2 #
3 # Stuff common to all debian.org servers
4 #
5 class debian-org {
6         if getfromhash($site::nodeinfo, 'hoster', 'mirror-debian') {
7                 $mirror = getfromhash($site::nodeinfo, 'hoster', 'mirror-debian')
8         } else {
9                 #$mirror = 'http://ftp.debian.org/debian/'
10                 $mirror = 'http://deb.debian.org/debian/'
11         }
12         if $::lsbmajdistrelease < 7 {
13                 $mirror_backports = 'http://backports.debian.org/debian-backports/'
14         } else {
15                 $mirror_backports = $mirror
16         }
17
18         if $::lsbmajdistrelease <= 7 {
19                 $mungedcodename = $::lsbdistcodename
20         } elsif ($::debarchitecture in ['kfreebsd-amd64', 'kfreebsd-i386']) {
21                 $mungedcodename = "${::lsbdistcodename}-kfreebsd"
22         } else {
23                 $mungedcodename = $::lsbdistcodename
24         }
25
26         if $systemd {
27                 include systemd
28                 $servicefiles = 'present'
29         } else {
30                 $servicefiles = 'absent'
31         }
32
33         $debianadmin = [
34                 'debian-archive-debian-samhain-reports@master.debian.org',
35                 'debian-admin@ftbfs.de',
36                 'weasel@debian.org',
37                 'steve@lobefin.net',
38                 'paravoid@debian.org',
39                 'zumbi@kos.to'
40         ]
41
42         package { [
43                         'klogd',
44                         'sysklogd',
45                         'rsyslog',
46                         'os-prober',
47                         'apt-listchanges',
48                 ]:
49                 ensure => purged,
50         }
51         package { [
52                         'debian.org',
53                         'dsa-munin-plugins',
54                 ]:
55                 ensure => installed,
56                 tag    => extra_repo,
57         }
58         file { '/etc/ssh/ssh_known_hosts':
59                 ensure  => present,
60                 replace => false,
61                 mode    => '0644',
62                 source  => 'puppet:///modules/debian-org/basic-ssh_known_hosts'
63         }
64
65         if ($::lsbmajdistrelease >= 8) {
66                 $rubyfs_package = 'ruby-filesystem'
67         } elsif $::lsbmajdistrelease == 7  {
68                 $rubyfs_package = 'libfilesystem-ruby1.9'
69         } else {
70                 $rubyfs_package = 'libfilesystem-ruby1.8'
71         }
72         package { [
73                         'apt-utils',
74                         'bash-completion',
75                         'dnsutils',
76                         'less',
77                         'lsb-release',
78                         $rubyfs_package,
79                         'mtr-tiny',
80                         'nload',
81                         'pciutils',
82                 ]:
83                 ensure => installed,
84         }
85
86         munin::check { [
87                         'cpu',
88                         'entropy',
89                         'forks',
90                         'interrupts',
91                         'iostat',
92                         'irqstats',
93                         'load',
94                         'memory',
95                         'ntp_offset',
96                         'ntp_states',
97                         'open_files',
98                         'open_inodes',
99                         'processes',
100                         'swap',
101                         'uptime',
102                         'vmstat',
103                 ]:
104         }
105
106         if getfromhash($site::nodeinfo, 'broken-rtc') {
107                 package { 'fake-hwclock':
108                         ensure => installed,
109                         tag    => extra_repo,
110                 }
111         }
112
113         package { 'molly-guard':
114                 ensure => installed,
115         }
116         file { '/etc/molly-guard/run.d/10-check-kvm':
117                 mode    => '0755',
118                 source  => 'puppet:///modules/debian-org/molly-guard/10-check-kvm',
119                 require => Package['molly-guard'],
120         }
121         file { '/etc/molly-guard/run.d/15-acquire-reboot-lock':
122                 mode    => '0755',
123                 source  => 'puppet:///modules/debian-org/molly-guard/15-acquire-reboot-lock',
124                 require => Package['molly-guard'],
125         }
126
127         file { '/etc/apt/trusted-keys.d':
128                 ensure => absent,
129                 force  => true,
130         }
131
132         file { '/etc/apt/trusted.gpg':
133                 mode    => '0600',
134                 content => "",
135         }
136
137         site::aptrepo { 'security':
138                 url        => 'http://security-cdn.debian.org/',
139                 suite      => "${mungedcodename}/updates",
140                 components => ['main','contrib','non-free']
141         }
142         if $::lsbmajdistrelease < 7 {
143                 site::aptrepo { 'debian-lts':
144                         url        => $mirror,
145                         suite      => "${::lsbdistcodename}-lts",
146                         components => ['main','contrib','non-free']
147                 }
148         } else {
149                 site::aptrepo { 'debian-lts':
150                         ensure => absent,
151                 }
152         }
153
154         site::aptrepo { 'backports.debian.org':
155                 url        => $mirror_backports,
156                 suite      => "${::lsbdistcodename}-backports",
157                 components => ['main','contrib','non-free']
158         }
159
160         site::aptrepo { 'volatile':
161                 url        => $mirror,
162                 suite      => "${::lsbdistcodename}-updates",
163                 components => ['main','contrib','non-free']
164         }
165
166         if ($::hostname in []) {
167                 site::aptrepo { 'proposed-updates':
168                         url        => $mirror,
169                         suite      => "${::lsbdistcodename}-proposed-updates",
170                         components => ['main','contrib','non-free']
171                 }
172         } else {
173                 site::aptrepo { 'proposed-updates':
174                         ensure => absent,
175                 }
176         }
177
178         site::aptrepo { 'debian.org':
179                 ensure => absent,
180         }
181
182         site::aptrepo { 'db.debian.org':
183                 url        => 'http://db.debian.org/debian-admin',
184                 suite      => 'debian-all',
185                 components => 'main',
186                 key        => 'puppet:///modules/debian-org/db.debian.org.gpg',
187         }
188         site::aptrepo { 'db.debian.org-suite':
189                 url        => 'http://db.debian.org/debian-admin',
190                 suite      => $::lsbdistcodename,
191                 components => 'main',
192         }
193
194         augeas { 'inittab_replicate':
195                 context => '/files/etc/inittab',
196                 changes => [
197                         'set ud/runlevels 2345',
198                         'set ud/action respawn',
199                         'set ud/process "/usr/bin/ud-replicated -d"',
200                 ],
201                 notify  => Exec['init q'],
202         }
203
204         if getfromhash($site::nodeinfo, 'hoster', 'mirror-debian') {
205                 site::aptrepo { 'debian':
206                         url        => getfromhash($site::nodeinfo, 'hoster', 'mirror-debian'),
207                         suite      => $mungedcodename,
208                         components => ['main','contrib','non-free']
209                 }
210         }
211
212         file { '/etc/facter':
213                 ensure  => directory,
214                 purge   => true,
215                 force   => true,
216                 recurse => true,
217                 source  => 'puppet:///files/empty/',
218         }
219         file { '/etc/facter/facts.d':
220                 ensure => directory,
221         }
222         file { '/etc/facter/facts.d/debian_facts.yaml':
223                 content => template('debian-org/debian_facts.yaml.erb')
224         }
225         file { '/etc/apt/preferences':
226                 source => 'puppet:///modules/debian-org/apt.preferences',
227         }
228         file { '/etc/apt/apt.conf.d/local-compression':
229                 source => 'puppet:///modules/debian-org/apt.conf.d/local-compression',
230         }
231         file { '/etc/apt/apt.conf.d/local-recommends':
232                 source => 'puppet:///modules/debian-org/apt.conf.d/local-recommends',
233         }
234         file { '/etc/apt/apt.conf.d/local-pdiffs':
235                 source => 'puppet:///modules/debian-org/apt.conf.d/local-pdiffs',
236         }
237         file { '/etc/timezone':
238                 source => 'puppet:///modules/debian-org/timezone',
239                 notify => Exec['dpkg-reconfigure tzdata -pcritical -fnoninteractive'],
240         }
241         if $::hostname == handel {
242                 include puppetmaster::db
243                 $dbpassword = $puppetmaster::db::password
244         }
245         file { '/etc/puppet/puppet.conf':
246                 content => template('debian-org/puppet.conf.erb'),
247         }
248         file { '/etc/default/puppet':
249                 source => 'puppet:///modules/debian-org/puppet.default',
250         }
251         file { '/etc/systemd':
252                 ensure  => directory,
253                 mode => 0755,
254         }
255         file { '/etc/systemd/system':
256                 ensure  => directory,
257                 mode => 0755,
258         }
259         file { '/etc/systemd/system/ud-replicated.service':
260                 ensure => $servicefiles,
261                 source => 'puppet:///modules/debian-org/ud-replicated.service',
262                 notify => Exec['systemctl daemon-reload'],
263         }
264         if $systemd {
265                 file { '/etc/systemd/system/multi-user.target.wants/ud-replicated.service':
266                         ensure => 'link',
267                         target => '../ud-replicated.service',
268                         notify => Exec['systemctl daemon-reload'],
269                 }
270         }
271         file { '/etc/systemd/system/puppet.service':
272                 ensure => 'link',
273                 target => '/dev/null',
274                 notify => Exec['systemctl daemon-reload'],
275         }
276
277         file { '/etc/cron.d/dsa-puppet-stuff':
278                 content => template('debian-org/dsa-puppet-stuff.cron.erb'),
279                 require => Package['debian.org'],
280         }
281         file { '/etc/ldap/ldap.conf':
282                 require => Package['debian.org'],
283                 content  => template('debian-org/ldap.conf.erb'),
284         }
285         file { '/etc/pam.d/common-session':
286                 require => Package['debian.org'],
287                 content => template('debian-org/pam.common-session.erb'),
288         }
289         file { '/etc/pam.d/common-session-noninteractive':
290                 require => Package['debian.org'],
291                 content => template('debian-org/pam.common-session-noninteractive.erb'),
292         }
293         file { '/etc/rc.local':
294                 mode   => '0755',
295                 content => template('debian-org/rc.local.erb'),
296                 notify => Exec['service rc.local start'],
297         }
298         file { '/etc/dsa':
299                 ensure => directory,
300                 mode   => '0755',
301         }
302         file { '/etc/dsa/cron.ignore.dsa-puppet-stuff':
303                 source  => 'puppet:///modules/debian-org/dsa-puppet-stuff.cron.ignore',
304                 require => Package['debian.org']
305         }
306         file { '/etc/nsswitch.conf':
307                 mode   => '0755',
308                 source => 'puppet:///modules/debian-org/nsswitch.conf',
309         }
310
311         # set mmap_min_addr to 4096 to mitigate
312         # Linux NULL-pointer dereference exploits
313         site::sysctl { 'mmap_min_addr':
314                 ensure => absent
315         }
316         site::sysctl { 'perf_event_paranoid':
317                 key   => 'kernel.perf_event_paranoid',
318                 value => '2',
319         }
320         site::alternative { 'editor':
321                 linkto => '/usr/bin/vim.basic',
322         }
323         site::alternative { 'view':
324                 linkto => '/usr/bin/vim.basic',
325         }
326         mailalias { 'samhain-reports':
327                 ensure    => present,
328                 recipient => $debianadmin,
329                 require   => Package['debian.org']
330         }
331
332         file { '/usr/local/bin/check_for_updates':
333                 source => 'puppet:///modules/debian-org/check_for_updates',
334                 mode   => '0755',
335                 owner  => root,
336                 group  => root,
337         }
338
339         exec { 'apt-get update':
340                 path    => '/usr/bin:/usr/sbin:/bin:/sbin',
341                 onlyif  => '/usr/local/bin/check_for_updates',
342                 require => File['/usr/local/bin/check_for_updates']
343         }
344         Exec['apt-get update']->Package<| tag == extra_repo |>
345
346         exec { 'dpkg-reconfigure tzdata -pcritical -fnoninteractive':
347                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
348                 refreshonly => true
349         }
350         exec { 'service puppetmaster restart':
351                 refreshonly => true
352         }
353         exec { 'service rc.local start':
354                 refreshonly => true
355         }
356         exec { 'init q':
357                 refreshonly => true
358         }
359
360         exec { 'systemctl daemon-reload':
361                 refreshonly => true,
362                 onlyif  => "test -x /bin/systemctl"
363         }
364
365         exec { 'systemd-tmpfiles --create --exclude-prefix=/dev':
366                 refreshonly => true,
367                 onlyif  => "test -x /bin/systemd-tmpfiles"
368         }
369
370         tidy { '/var/lib/puppet/clientbucket/':
371                 age      => '2w',
372                 recurse  => 9,
373                 type     => ctime,
374                 matches  => [ 'paths', 'contents' ],
375                 schedule => weekly
376         }
377
378         file { '/root/.bashrc':
379                 source => 'puppet:///modules/debian-org/root-dotfiles/bashrc',
380         }
381         file { '/root/.profile':
382                 source => 'puppet:///modules/debian-org/root-dotfiles/profile',
383         }
384         file { '/root/.screenrc':
385                 source => 'puppet:///modules/debian-org/root-dotfiles/screenrc',
386         }
387         file { '/root/.vimrc':
388                 source => 'puppet:///modules/debian-org/root-dotfiles/vimrc',
389         }
390 }