Mask proc-sys-fs-binfmt_misc.automount
[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
154         site::aptrepo { 'volatile':
155                 url        => $mirror,
156                 suite      => "${::lsbdistcodename}-updates",
157                 components => ['main','contrib','non-free']
158         }
159
160         if ($::hostname in [] or $::debarchitecture in ['kfreebsd-amd64', 'kfreebsd-i386']) {
161                 site::aptrepo { 'proposed-updates':
162                         url        => $mirror,
163                         suite      => "${mungedcodename}-proposed-updates",
164                         components => ['main','contrib','non-free']
165                 }
166         } else {
167                 site::aptrepo { 'proposed-updates':
168                         ensure => absent,
169                 }
170         }
171
172         site::aptrepo { 'debian.org':
173                 ensure => absent,
174         }
175
176         site::aptrepo { 'db.debian.org':
177                 url        => 'http://db.debian.org/debian-admin',
178                 suite      => 'debian-all',
179                 components => 'main',
180                 key        => 'puppet:///modules/debian-org/db.debian.org.gpg',
181         }
182         site::aptrepo { 'db.debian.org-suite':
183                 url        => 'http://db.debian.org/debian-admin',
184                 suite      => $::lsbdistcodename,
185                 components => 'main',
186         }
187
188         augeas { 'inittab_replicate':
189                 context => '/files/etc/inittab',
190                 changes => [
191                         'set ud/runlevels 2345',
192                         'set ud/action respawn',
193                         'set ud/process "/usr/bin/ud-replicated -d"',
194                 ],
195                 notify  => Exec['init q'],
196         }
197
198         if getfromhash($site::nodeinfo, 'hoster', 'mirror-debian') {
199                 site::aptrepo { 'debian':
200                         url        => getfromhash($site::nodeinfo, 'hoster', 'mirror-debian'),
201                         suite      => $mungedcodename,
202                         components => ['main','contrib','non-free']
203                 }
204         }
205         site::aptrepo { 'debian-cdn':
206                 ensure => absent,
207         }
208
209         site::aptrepo { 'debian2':
210                 url        => "http://cdn-fastly.deb.debian.org/debian",
211                 suite      => $mungedcodename,
212                 components => ['main','contrib','non-free']
213         }
214
215         file { '/etc/facter':
216                 ensure  => directory,
217                 purge   => true,
218                 force   => true,
219                 recurse => true,
220                 source  => 'puppet:///files/empty/',
221         }
222         file { '/etc/facter/facts.d':
223                 ensure => directory,
224         }
225         file { '/etc/facter/facts.d/debian_facts.yaml':
226                 content => template('debian-org/debian_facts.yaml.erb')
227         }
228         file { '/etc/apt/preferences':
229                 source => 'puppet:///modules/debian-org/apt.preferences',
230         }
231         file { '/etc/apt/apt.conf.d/local-compression':
232                 source => 'puppet:///modules/debian-org/apt.conf.d/local-compression',
233         }
234         file { '/etc/apt/apt.conf.d/local-recommends':
235                 source => 'puppet:///modules/debian-org/apt.conf.d/local-recommends',
236         }
237         file { '/etc/apt/apt.conf.d/local-pdiffs':
238                 source => 'puppet:///modules/debian-org/apt.conf.d/local-pdiffs',
239         }
240         file { '/etc/apt/apt.conf.d/local-langs':
241                 source => 'puppet:///modules/debian-org/apt.conf.d/local-langs',
242         }
243         file { '/etc/timezone':
244                 source => 'puppet:///modules/debian-org/timezone',
245                 notify => Exec['dpkg-reconfigure tzdata -pcritical -fnoninteractive'],
246         }
247         if $::hostname == handel {
248                 include puppetmaster::db
249                 $dbpassword = $puppetmaster::db::password
250         }
251         file { '/etc/puppet/puppet.conf':
252                 content => template('debian-org/puppet.conf.erb'),
253         }
254         file { '/etc/default/puppet':
255                 source => 'puppet:///modules/debian-org/puppet.default',
256         }
257         file { '/etc/systemd':
258                 ensure  => directory,
259                 mode => 0755,
260         }
261         file { '/etc/systemd/system':
262                 ensure  => directory,
263                 mode => 0755,
264         }
265         file { '/etc/systemd/system/ud-replicated.service':
266                 ensure => $servicefiles,
267                 source => 'puppet:///modules/debian-org/ud-replicated.service',
268                 notify => Exec['systemctl daemon-reload'],
269         }
270         if $systemd {
271                 file { '/etc/systemd/system/multi-user.target.wants/ud-replicated.service':
272                         ensure => 'link',
273                         target => '../ud-replicated.service',
274                         notify => Exec['systemctl daemon-reload'],
275                 }
276         }
277         file { '/etc/systemd/system/puppet.service':
278                 ensure => 'link',
279                 target => '/dev/null',
280                 notify => Exec['systemctl daemon-reload'],
281         }
282         file { '/etc/systemd/system/proc-sys-fs-binfmt_misc.automount':
283                 ensure => 'link',
284                 target => '/dev/null',
285                 notify => Exec['systemctl daemon-reload'],
286         }
287
288         file { '/etc/cron.d/dsa-puppet-stuff':
289                 content => template('debian-org/dsa-puppet-stuff.cron.erb'),
290                 require => Package['debian.org'],
291         }
292         file { '/etc/ldap/ldap.conf':
293                 require => Package['debian.org'],
294                 content  => template('debian-org/ldap.conf.erb'),
295         }
296         file { '/etc/pam.d/common-session':
297                 require => Package['debian.org'],
298                 content => template('debian-org/pam.common-session.erb'),
299         }
300         file { '/etc/pam.d/common-session-noninteractive':
301                 require => Package['debian.org'],
302                 content => template('debian-org/pam.common-session-noninteractive.erb'),
303         }
304         file { '/etc/rc.local':
305                 mode   => '0755',
306                 content => template('debian-org/rc.local.erb'),
307                 notify => Exec['service rc.local start'],
308         }
309         file { '/etc/dsa':
310                 ensure => directory,
311                 mode   => '0755',
312         }
313         file { '/etc/dsa/cron.ignore.dsa-puppet-stuff':
314                 source  => 'puppet:///modules/debian-org/dsa-puppet-stuff.cron.ignore',
315                 require => Package['debian.org']
316         }
317         file { '/etc/nsswitch.conf':
318                 mode   => '0755',
319                 source => 'puppet:///modules/debian-org/nsswitch.conf',
320         }
321
322         file { '/etc/profile.d/timeout.sh':
323                 mode   => '0555',
324                 source => 'puppet:///modules/debian-org/etc.profile.d/timeout.sh',
325         }
326         file { '/etc/zsh':
327                 ensure => directory,
328         }
329         file { '/etc/zsh/zprofile':
330                 mode   => '0444',
331                 source => 'puppet:///modules/debian-org/etc.zsh/zprofile',
332         }
333
334         # set mmap_min_addr to 4096 to mitigate
335         # Linux NULL-pointer dereference exploits
336         site::sysctl { 'mmap_min_addr':
337                 ensure => absent
338         }
339         site::sysctl { 'perf_event_paranoid':
340                 key   => 'kernel.perf_event_paranoid',
341                 value => '2',
342         }
343         site::alternative { 'editor':
344                 linkto => '/usr/bin/vim.basic',
345         }
346         site::alternative { 'view':
347                 linkto => '/usr/bin/vim.basic',
348         }
349         mailalias { 'samhain-reports':
350                 ensure    => present,
351                 recipient => $debianadmin,
352                 require   => Package['debian.org']
353         }
354
355         file { '/usr/local/bin/check_for_updates':
356                 source => 'puppet:///modules/debian-org/check_for_updates',
357                 mode   => '0755',
358                 owner  => root,
359                 group  => root,
360         }
361
362         exec { 'apt-get update':
363                 path    => '/usr/bin:/usr/sbin:/bin:/sbin',
364                 onlyif  => '/usr/local/bin/check_for_updates',
365                 require => File['/usr/local/bin/check_for_updates']
366         }
367         Exec['apt-get update']->Package<| tag == extra_repo |>
368
369         exec { 'dpkg-reconfigure tzdata -pcritical -fnoninteractive':
370                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
371                 refreshonly => true
372         }
373         exec { 'service puppetmaster restart':
374                 refreshonly => true
375         }
376         exec { 'service rc.local start':
377                 refreshonly => true
378         }
379         exec { 'init q':
380                 refreshonly => true
381         }
382
383         exec { 'systemctl daemon-reload':
384                 refreshonly => true,
385                 onlyif  => "test -x /bin/systemctl"
386         }
387
388         exec { 'systemd-tmpfiles --create --exclude-prefix=/dev':
389                 refreshonly => true,
390                 onlyif  => "test -x /bin/systemd-tmpfiles"
391         }
392
393         tidy { '/var/lib/puppet/clientbucket/':
394                 age      => '2w',
395                 recurse  => 9,
396                 type     => ctime,
397                 matches  => [ 'paths', 'contents' ],
398                 schedule => weekly
399         }
400
401         file { '/root/.bashrc':
402                 source => 'puppet:///modules/debian-org/root-dotfiles/bashrc',
403         }
404         file { '/root/.profile':
405                 source => 'puppet:///modules/debian-org/root-dotfiles/profile',
406         }
407         file { '/root/.screenrc':
408                 source => 'puppet:///modules/debian-org/root-dotfiles/screenrc',
409         }
410         file { '/root/.vimrc':
411                 source => 'puppet:///modules/debian-org/root-dotfiles/vimrc',
412         }
413 }