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