debian-org: squeeze cleanup
[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
201         file { '/etc/facter':
202                 ensure  => directory,
203                 purge   => true,
204                 force   => true,
205                 recurse => true,
206                 source  => 'puppet:///files/empty/',
207         }
208         file { '/etc/facter/facts.d':
209                 ensure => directory,
210         }
211         file { '/etc/facter/facts.d/debian_facts.yaml':
212                 content => template('debian-org/debian_facts.yaml.erb')
213         }
214         file { '/etc/apt/preferences':
215                 source => 'puppet:///modules/debian-org/apt.preferences',
216         }
217         file { '/etc/apt/apt.conf.d/local-compression':
218                 source => 'puppet:///modules/debian-org/apt.conf.d/local-compression',
219         }
220         file { '/etc/apt/apt.conf.d/local-recommends':
221                 source => 'puppet:///modules/debian-org/apt.conf.d/local-recommends',
222         }
223         file { '/etc/apt/apt.conf.d/local-pdiffs':
224                 source => 'puppet:///modules/debian-org/apt.conf.d/local-pdiffs',
225         }
226         file { '/etc/timezone':
227                 source => 'puppet:///modules/debian-org/timezone',
228                 notify => Exec['dpkg-reconfigure tzdata -pcritical -fnoninteractive'],
229         }
230         if $::hostname == handel {
231                 include puppetmaster::db
232                 $dbpassword = $puppetmaster::db::password
233         }
234         file { '/etc/puppet/puppet.conf':
235                 content => template('debian-org/puppet.conf.erb'),
236         }
237         file { '/etc/default/puppet':
238                 source => 'puppet:///modules/debian-org/puppet.default',
239         }
240         file { '/etc/systemd':
241                 ensure  => directory,
242                 mode => 0755,
243         }
244         file { '/etc/systemd/system':
245                 ensure  => directory,
246                 mode => 0755,
247         }
248         file { '/etc/systemd/system/ud-replicated.service':
249                 ensure => $servicefiles,
250                 source => 'puppet:///modules/debian-org/ud-replicated.service',
251                 notify => Exec['systemctl daemon-reload'],
252         }
253         if $systemd {
254                 file { '/etc/systemd/system/multi-user.target.wants/ud-replicated.service':
255                         ensure => 'link',
256                         target => '../ud-replicated.service',
257                         notify => Exec['systemctl daemon-reload'],
258                 }
259         }
260         file { '/etc/systemd/system/puppet.service':
261                 ensure => 'link',
262                 target => '/dev/null',
263                 notify => Exec['systemctl daemon-reload'],
264         }
265
266         file { '/etc/cron.d/dsa-puppet-stuff':
267                 content => template('debian-org/dsa-puppet-stuff.cron.erb'),
268                 require => Package['debian.org'],
269         }
270         file { '/etc/ldap/ldap.conf':
271                 require => Package['debian.org'],
272                 content  => template('debian-org/ldap.conf.erb'),
273         }
274         file { '/etc/pam.d/common-session':
275                 require => Package['debian.org'],
276                 content => template('debian-org/pam.common-session.erb'),
277         }
278         file { '/etc/pam.d/common-session-noninteractive':
279                 require => Package['debian.org'],
280                 content => template('debian-org/pam.common-session-noninteractive.erb'),
281         }
282         file { '/etc/rc.local':
283                 mode   => '0755',
284                 content => template('debian-org/rc.local.erb'),
285                 notify => Exec['service rc.local start'],
286         }
287         file { '/etc/dsa':
288                 ensure => directory,
289                 mode   => '0755',
290         }
291         file { '/etc/dsa/cron.ignore.dsa-puppet-stuff':
292                 source  => 'puppet:///modules/debian-org/dsa-puppet-stuff.cron.ignore',
293                 require => Package['debian.org']
294         }
295         file { '/etc/nsswitch.conf':
296                 mode   => '0755',
297                 source => 'puppet:///modules/debian-org/nsswitch.conf',
298         }
299
300         # set mmap_min_addr to 4096 to mitigate
301         # Linux NULL-pointer dereference exploits
302         site::sysctl { 'mmap_min_addr':
303                 ensure => absent
304         }
305         site::sysctl { 'perf_event_paranoid':
306                 key   => 'kernel.perf_event_paranoid',
307                 value => '2',
308         }
309         site::alternative { 'editor':
310                 linkto => '/usr/bin/vim.basic',
311         }
312         site::alternative { 'view':
313                 linkto => '/usr/bin/vim.basic',
314         }
315         mailalias { 'samhain-reports':
316                 ensure    => present,
317                 recipient => $debianadmin,
318                 require   => Package['debian.org']
319         }
320
321         file { '/usr/local/bin/check_for_updates':
322                 source => 'puppet:///modules/debian-org/check_for_updates',
323                 mode   => '0755',
324                 owner  => root,
325                 group  => root,
326         }
327
328         exec { 'apt-get update':
329                 path    => '/usr/bin:/usr/sbin:/bin:/sbin',
330                 onlyif  => '/usr/local/bin/check_for_updates',
331                 require => File['/usr/local/bin/check_for_updates']
332         }
333         Exec['apt-get update']->Package<| tag == extra_repo |>
334
335         exec { 'dpkg-reconfigure tzdata -pcritical -fnoninteractive':
336                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
337                 refreshonly => true
338         }
339         exec { 'service puppetmaster restart':
340                 refreshonly => true
341         }
342         exec { 'service rc.local start':
343                 refreshonly => true
344         }
345         exec { 'init q':
346                 refreshonly => true
347         }
348
349         exec { 'systemctl daemon-reload':
350                 refreshonly => true,
351                 onlyif  => "test -x /bin/systemctl"
352         }
353
354         exec { 'systemd-tmpfiles --create --exclude-prefix=/dev':
355                 refreshonly => true,
356                 onlyif  => "test -x /bin/systemd-tmpfiles"
357         }
358
359         tidy { '/var/lib/puppet/clientbucket/':
360                 age      => '2w',
361                 recurse  => 9,
362                 type     => ctime,
363                 matches  => [ 'paths', 'contents' ],
364                 schedule => weekly
365         }
366
367         file { '/root/.bashrc':
368                 source => 'puppet:///modules/debian-org/root-dotfiles/bashrc',
369         }
370         file { '/root/.profile':
371                 source => 'puppet:///modules/debian-org/root-dotfiles/profile',
372         }
373         file { '/root/.screenrc':
374                 source => 'puppet:///modules/debian-org/root-dotfiles/screenrc',
375         }
376         file { '/root/.vimrc':
377                 source => 'puppet:///modules/debian-org/root-dotfiles/vimrc',
378         }
379 }