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