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