Remove wheezy-supporting cruft
[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         include debian_org::apt
7
8         if $systemd {
9                 include systemd
10                 $servicefiles = 'present'
11         } else {
12                 $servicefiles = 'absent'
13         }
14
15         # the virtual facter needs virt-what on jessie to work
16         if versioncmp($::lsbmajdistrelease, '9') < 0 {
17                 package { 'virt-what': ensure => installed }
18         } else {
19                 package { 'virt-what': ensure => purged }
20         }
21
22         $samhain_recipients = hiera('samhain_recipients')
23         $root_mail_alias = hiera('root_mail_alias')
24
25         package { [
26                         'klogd',
27                         'sysklogd',
28                         'rsyslog',
29                         'os-prober',
30                         'apt-listchanges',
31                         'mlocate',
32                 ]:
33                 ensure => purged,
34         }
35         package { [
36                         'debian.org',
37                         'debian.org-recommended',
38                         'dsa-munin-plugins',
39                         'userdir-ldap',
40                 ]:
41                 ensure => installed,
42                 tag    => extra_repo,
43         }
44
45         package { [
46                         'apt-utils',
47                         'bash-completion',
48                         'dnsutils',
49                         'less',
50                         'lsb-release',
51                         'ruby-filesystem',
52                         'mtr-tiny',
53                         'nload',
54                         'pciutils',
55                         'lldpd',
56                 ]:
57                 ensure => installed,
58         }
59
60         munin::check { [
61                         'cpu',
62                         'entropy',
63                         'forks',
64                         'interrupts',
65                         'iostat',
66                         'irqstats',
67                         'load',
68                         'memory',
69                         'open_files',
70                         'open_inodes',
71                         'processes',
72                         'swap',
73                         'uptime',
74                         'vmstat',
75                 ]:
76         }
77
78         if getfromhash($site::nodeinfo, 'broken-rtc') {
79                 package { 'fake-hwclock':
80                         ensure => installed,
81                         tag    => extra_repo,
82                 }
83         }
84
85         package { 'molly-guard':
86                 ensure => installed,
87         }
88         file { '/etc/molly-guard/run.d/10-check-kvm':
89                 mode    => '0755',
90                 source  => 'puppet:///modules/debian_org/molly-guard/10-check-kvm',
91                 require => Package['molly-guard'],
92         }
93         file { '/etc/molly-guard/run.d/15-acquire-reboot-lock':
94                 mode    => '0755',
95                 source  => 'puppet:///modules/debian_org/molly-guard/15-acquire-reboot-lock',
96                 require => Package['molly-guard'],
97         }
98
99         augeas { 'inittab_replicate':
100                 context => '/files/etc/inittab',
101                 changes => [
102                         'set ud/runlevels 2345',
103                         'set ud/action respawn',
104                         'set ud/process "/usr/bin/ud-replicated -d"',
105                 ],
106                 notify  => Exec['init q'],
107         }
108
109
110         file { '/etc/facter':
111                 ensure  => directory,
112                 purge   => true,
113                 force   => true,
114                 recurse => true,
115                 source  => 'puppet:///files/empty/',
116         }
117         file { '/etc/facter/facts.d':
118                 ensure => directory,
119         }
120         file { '/etc/facter/facts.d/debian_facts.yaml':
121                 content => template('debian_org/debian_facts.yaml.erb')
122         }
123         file { '/etc/timezone':
124                 source => 'puppet:///modules/debian_org/timezone',
125                 notify => Exec['dpkg-reconfigure tzdata -pcritical -fnoninteractive'],
126         }
127         if $::hostname == handel {
128                 include puppetmaster::db
129                 $dbpassword = $puppetmaster::db::password
130         }
131         file { '/etc/puppet/puppet.conf':
132                 content => template('debian_org/puppet.conf.erb'),
133                 mode => '0440',
134                 group => 'puppet',
135         }
136         file { '/etc/default/puppet':
137                 source => 'puppet:///modules/debian_org/puppet.default',
138         }
139         file { '/etc/systemd':
140                 ensure  => directory,
141                 mode => '0755',
142         }
143         file { '/etc/systemd/system':
144                 ensure  => directory,
145                 mode => '0755',
146         }
147         file { '/etc/systemd/system/ud-replicated.service':
148                 ensure => $servicefiles,
149                 source => 'puppet:///modules/debian_org/ud-replicated.service',
150                 notify => Exec['systemctl daemon-reload'],
151         }
152         if $systemd {
153                 file { '/etc/systemd/system/multi-user.target.wants/ud-replicated.service':
154                         ensure => 'link',
155                         target => '../ud-replicated.service',
156                         notify => Exec['systemctl daemon-reload'],
157                 }
158         }
159         file { '/etc/systemd/system/puppet.service':
160                 ensure => 'link',
161                 target => '/dev/null',
162                 notify => Exec['systemctl daemon-reload'],
163         }
164         file { '/etc/systemd/system/proc-sys-fs-binfmt_misc.automount':
165                 ensure => 'link',
166                 target => '/dev/null',
167                 notify => Exec['systemctl daemon-reload'],
168         }
169
170         concat { '/etc/cron.d/dsa-puppet-stuff': }
171         concat::fragment { 'dsa-puppet-stuff---header':
172                 target => '/etc/cron.d/dsa-puppet-stuff',
173                 order  => '000',
174                 content  => @(EOF)
175                         ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
176                         SHELL=/bin/bash
177                         MAILTO=root
178                         PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/nagios/plugins
179                         | EOF
180         }
181         concat::fragment { 'dsa-puppet-stuff---all':
182                 target => '/etc/cron.d/dsa-puppet-stuff',
183                 order  => '010',
184                 content => template('debian_org/dsa-puppet-stuff.cron.erb'),
185                 require => Package['debian.org'],
186         }
187         file { '/etc/ldap/ldap.conf':
188                 require => Package['debian.org'],
189                 content  => template('debian_org/ldap.conf.erb'),
190         }
191         file { '/etc/pam.d/common-session':
192                 require => Package['debian.org'],
193                 content => template('debian_org/pam.common-session.erb'),
194         }
195         file { '/etc/pam.d/common-session-noninteractive':
196                 require => Package['debian.org'],
197                 content => template('debian_org/pam.common-session-noninteractive.erb'),
198         }
199         file { '/etc/rc.local':
200                 mode   => '0755',
201                 content => template('debian_org/rc.local.erb'),
202                 notify => Exec['service rc.local restart'],
203         }
204         file { '/etc/dsa':
205                 ensure => directory,
206                 mode   => '0755',
207         }
208         file { '/etc/dsa/cron.ignore.dsa-puppet-stuff':
209                 source  => 'puppet:///modules/debian_org/dsa-puppet-stuff.cron.ignore',
210                 require => Package['debian.org']
211         }
212         file { '/etc/nsswitch.conf':
213                 mode   => '0755',
214                 source => 'puppet:///modules/debian_org/nsswitch.conf',
215         }
216
217         file { '/etc/profile.d/timeout.sh':
218                 mode   => '0555',
219                 source => 'puppet:///modules/debian_org/etc.profile.d/timeout.sh',
220         }
221         file { '/etc/zsh':
222                 ensure => directory,
223         }
224         file { '/etc/zsh/zprofile':
225                 mode   => '0444',
226                 source => 'puppet:///modules/debian_org/etc.zsh/zprofile',
227         }
228         file { '/etc/environment':
229                 content => "",
230                 mode => '0440',
231         }
232         file { '/etc/default/locale':
233                 content => "",
234                 mode => '0444',
235         }
236
237         # set mmap_min_addr to 4096 to mitigate
238         # Linux NULL-pointer dereference exploits
239         site::sysctl { 'mmap_min_addr':
240                 ensure => absent
241         }
242         site::sysctl { 'perf_event_paranoid':
243                 key   => 'kernel.perf_event_paranoid',
244                 value => '2',
245         }
246         site::sysctl { 'puppet-vfs_cache_pressure':
247                 key   => 'vm.vfs_cache_pressure',
248                 value => '10',
249         }
250         site::alternative { 'editor':
251                 linkto => '/usr/bin/vim.basic',
252         }
253         site::alternative { 'view':
254                 linkto => '/usr/bin/vim.basic',
255         }
256         mailalias { 'samhain-reports':
257                 ensure    => present,
258                 recipient => $samhain_recipients,
259                 require   => Package['debian.org']
260         }
261         mailalias { 'root':
262                 ensure    => present,
263                 recipient => $root_mail_alias,
264                 require   => Package['debian.org']
265         }
266
267         file { '/usr/local/bin/check_for_updates':
268                 source => 'puppet:///modules/debian_org/check_for_updates',
269                 mode   => '0755',
270                 owner  => root,
271                 group  => root,
272         }
273         file { '/usr/local/bin/dsa-is-shutdown-scheduled':
274                 source  => 'puppet:///modules/debian_org/dsa-is-shutdown-scheduled',
275                 mode    => '0555',
276         }
277
278         exec { 'dpkg-reconfigure tzdata -pcritical -fnoninteractive':
279                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
280                 refreshonly => true
281         }
282         exec { 'service puppetmaster restart':
283                 refreshonly => true
284         }
285         exec { 'service rc.local restart':
286                 refreshonly => true
287         }
288         exec { 'init q':
289                 refreshonly => true
290         }
291
292         exec { 'systemctl daemon-reload':
293                 refreshonly => true,
294                 onlyif  => "test -x /bin/systemctl"
295         }
296
297         exec { 'systemd-tmpfiles --create --exclude-prefix=/dev':
298                 refreshonly => true,
299                 onlyif  => "test -x /bin/systemd-tmpfiles"
300         }
301
302         tidy { '/var/lib/puppet/clientbucket/':
303                 age      => '2w',
304                 recurse  => 9,
305                 type     => ctime,
306                 matches  => [ 'paths', 'contents' ],
307                 schedule => weekly
308         }
309
310         file { '/root/.bashrc':
311                 source => 'puppet:///modules/debian_org/root-dotfiles/bashrc',
312         }
313         file { '/root/.profile':
314                 source => 'puppet:///modules/debian_org/root-dotfiles/profile',
315         }
316         file { '/root/.selected_editor':
317                 source => 'puppet:///modules/debian_org/root-dotfiles/selected_editor',
318         }
319         file { '/root/.screenrc':
320                 source => 'puppet:///modules/debian_org/root-dotfiles/screenrc',
321         }
322         file { '/root/.tmux.conf':
323                 source => 'puppet:///modules/debian_org/root-dotfiles/tmux.conf',
324         }
325         file { '/root/.vimrc':
326                 source => 'puppet:///modules/debian_org/root-dotfiles/vimrc',
327         }
328
329         if versioncmp($::lsbmajdistrelease, '9') >= 0 { # older puppets do facts as strings.
330                 if $::processorcount > 1 {
331                         package { 'irqbalance': ensure => installed }
332                 }
333         }
334
335
336         # https://www.decadent.org.uk/ben/blog/bpf-security-issues-in-debian.html
337         site::sysctl { 'unprivileged_bpf_disabled':
338                 key   => 'kernel.unprivileged_bpf_disabled',
339                 value => '1',
340         }
341
342         # Disable kpartx udev rules
343         file { '/etc/udev/rules.d/60-kpartx.rules':
344                 ensure => $has_lib_udev_rules_d_60_kpartx_rules ? { true  => 'present', default => 'absent' },
345                 content => "",
346                 mode => '0444',
347         }
348
349         # this is only to avoid warnings, else puppet will complain that we
350         # have a symlink there, even if we're not replacing it anyhow.
351         if ! $has_etc_ssh_ssh_known_hosts {
352                 file { '/etc/ssh/ssh_known_hosts':
353                         ensure  => 'present',
354                         replace => 'no',
355                         content => inline_template('<%= open("/etc/ssh/ssh_known_hosts").read() %>'),
356                         notify  => Exec['ud-replicate'],
357                 }
358         }
359
360         exec { 'ud-replicate':
361                 path => '/usr/bin:/usr/sbin:/bin:/sbin',
362                 command => '/usr/bin/ud-replicate',
363                 refreshonly => true,
364                 require => Package['userdir-ldap']
365         }
366 }