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