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