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