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