Install userdir-ldap
[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         include debian_org::apt
7
8         if $systemd {
9                 include systemd
10                 $servicefiles = 'present'
11         } else {
12                 $servicefiles = 'absent'
13         }
14
15         # the virtual facter needs virt-what on jessie to work
16         if versioncmp($::lsbmajdistrelease, '9') < 0 {
17                 package { 'virt-what': ensure => installed }
18         } else {
19                 package { 'virt-what': ensure => purged }
20         }
21
22         $debianadmin = [
23                 'debian-archive-debian-samhain-reports@master.debian.org',
24                 'debian-admin@ftbfs.de',
25                 'weasel@debian.org',
26                 'steve@lobefin.net',
27                 'zumbi@oron.es'
28         ]
29
30         package { [
31                         'klogd',
32                         'sysklogd',
33                         'rsyslog',
34                         'os-prober',
35                         'apt-listchanges',
36                         'mlocate',
37                 ]:
38                 ensure => purged,
39         }
40         package { [
41                         'debian.org',
42                         'debian.org-recommended',
43                         'dsa-munin-plugins',
44                         'userdir-ldap',
45                 ]:
46                 ensure => installed,
47                 tag    => extra_repo,
48         }
49         file { '/etc/ssh/ssh_known_hosts':
50                 ensure  => present,
51                 replace => false,
52                 mode    => '0644',
53                 source  => 'puppet:///modules/debian_org/basic-ssh_known_hosts'
54         }
55
56         if versioncmp($::lsbmajdistrelease, '8') >= 0 {
57                 $rubyfs_package = 'ruby-filesystem'
58         } else {
59                 $rubyfs_package = 'libfilesystem-ruby1.9'
60         }
61         package { [
62                         'apt-utils',
63                         'bash-completion',
64                         'dnsutils',
65                         'less',
66                         'lsb-release',
67                         $rubyfs_package,
68                         'mtr-tiny',
69                         'nload',
70                         'pciutils',
71                         'lldpd',
72                 ]:
73                 ensure => installed,
74         }
75
76         munin::check { [
77                         'cpu',
78                         'entropy',
79                         'forks',
80                         'interrupts',
81                         'iostat',
82                         'irqstats',
83                         'load',
84                         'memory',
85                         'open_files',
86                         'open_inodes',
87                         'processes',
88                         'swap',
89                         'uptime',
90                         'vmstat',
91                 ]:
92         }
93
94         if getfromhash($site::nodeinfo, 'broken-rtc') {
95                 package { 'fake-hwclock':
96                         ensure => installed,
97                         tag    => extra_repo,
98                 }
99         }
100
101         package { 'molly-guard':
102                 ensure => installed,
103         }
104         file { '/etc/molly-guard/run.d/10-check-kvm':
105                 mode    => '0755',
106                 source  => 'puppet:///modules/debian_org/molly-guard/10-check-kvm',
107                 require => Package['molly-guard'],
108         }
109         file { '/etc/molly-guard/run.d/15-acquire-reboot-lock':
110                 mode    => '0755',
111                 source  => 'puppet:///modules/debian_org/molly-guard/15-acquire-reboot-lock',
112                 require => Package['molly-guard'],
113         }
114
115         augeas { 'inittab_replicate':
116                 context => '/files/etc/inittab',
117                 changes => [
118                         'set ud/runlevels 2345',
119                         'set ud/action respawn',
120                         'set ud/process "/usr/bin/ud-replicated -d"',
121                 ],
122                 notify  => Exec['init q'],
123         }
124
125
126         file { '/etc/facter':
127                 ensure  => directory,
128                 purge   => true,
129                 force   => true,
130                 recurse => true,
131                 source  => 'puppet:///files/empty/',
132         }
133         file { '/etc/facter/facts.d':
134                 ensure => directory,
135         }
136         file { '/etc/facter/facts.d/debian_facts.yaml':
137                 content => template('debian_org/debian_facts.yaml.erb')
138         }
139         file { '/etc/timezone':
140                 source => 'puppet:///modules/debian_org/timezone',
141                 notify => Exec['dpkg-reconfigure tzdata -pcritical -fnoninteractive'],
142         }
143         if $::hostname == handel {
144                 include puppetmaster::db
145                 $dbpassword = $puppetmaster::db::password
146         }
147         file { '/etc/puppet/puppet.conf':
148                 content => template('debian_org/puppet.conf.erb'),
149                 mode => '0440',
150                 group => 'puppet',
151         }
152         file { '/etc/default/puppet':
153                 source => 'puppet:///modules/debian_org/puppet.default',
154         }
155         file { '/etc/systemd':
156                 ensure  => directory,
157                 mode => '0755',
158         }
159         file { '/etc/systemd/system':
160                 ensure  => directory,
161                 mode => '0755',
162         }
163         file { '/etc/systemd/system/ud-replicated.service':
164                 ensure => $servicefiles,
165                 source => 'puppet:///modules/debian_org/ud-replicated.service',
166                 notify => Exec['systemctl daemon-reload'],
167         }
168         if $systemd {
169                 file { '/etc/systemd/system/multi-user.target.wants/ud-replicated.service':
170                         ensure => 'link',
171                         target => '../ud-replicated.service',
172                         notify => Exec['systemctl daemon-reload'],
173                 }
174         }
175         file { '/etc/systemd/system/puppet.service':
176                 ensure => 'link',
177                 target => '/dev/null',
178                 notify => Exec['systemctl daemon-reload'],
179         }
180         file { '/etc/systemd/system/proc-sys-fs-binfmt_misc.automount':
181                 ensure => 'link',
182                 target => '/dev/null',
183                 notify => Exec['systemctl daemon-reload'],
184         }
185
186         file { '/etc/cron.d/dsa-puppet-stuff':
187                 content => template('debian_org/dsa-puppet-stuff.cron.erb'),
188                 require => Package['debian.org'],
189         }
190         file { '/etc/ldap/ldap.conf':
191                 require => Package['debian.org'],
192                 content  => template('debian_org/ldap.conf.erb'),
193         }
194         file { '/etc/pam.d/common-session':
195                 require => Package['debian.org'],
196                 content => template('debian_org/pam.common-session.erb'),
197         }
198         file { '/etc/pam.d/common-session-noninteractive':
199                 require => Package['debian.org'],
200                 content => template('debian_org/pam.common-session-noninteractive.erb'),
201         }
202         file { '/etc/rc.local':
203                 mode   => '0755',
204                 content => template('debian_org/rc.local.erb'),
205                 notify => Exec['service rc.local restart'],
206         }
207         file { '/etc/dsa':
208                 ensure => directory,
209                 mode   => '0755',
210         }
211         file { '/etc/dsa/cron.ignore.dsa-puppet-stuff':
212                 source  => 'puppet:///modules/debian_org/dsa-puppet-stuff.cron.ignore',
213                 require => Package['debian.org']
214         }
215         file { '/etc/nsswitch.conf':
216                 mode   => '0755',
217                 source => 'puppet:///modules/debian_org/nsswitch.conf',
218         }
219
220         file { '/etc/profile.d/timeout.sh':
221                 mode   => '0555',
222                 source => 'puppet:///modules/debian_org/etc.profile.d/timeout.sh',
223         }
224         file { '/etc/zsh':
225                 ensure => directory,
226         }
227         file { '/etc/zsh/zprofile':
228                 mode   => '0444',
229                 source => 'puppet:///modules/debian_org/etc.zsh/zprofile',
230         }
231
232         # set mmap_min_addr to 4096 to mitigate
233         # Linux NULL-pointer dereference exploits
234         site::sysctl { 'mmap_min_addr':
235                 ensure => absent
236         }
237         site::sysctl { 'perf_event_paranoid':
238                 key   => 'kernel.perf_event_paranoid',
239                 value => '2',
240         }
241         site::sysctl { 'puppet-vfs_cache_pressure':
242                 key   => 'vm.vfs_cache_pressure',
243                 value => '10',
244         }
245         site::alternative { 'editor':
246                 linkto => '/usr/bin/vim.basic',
247         }
248         site::alternative { 'view':
249                 linkto => '/usr/bin/vim.basic',
250         }
251         mailalias { 'samhain-reports':
252                 ensure    => present,
253                 recipient => $debianadmin,
254                 require   => Package['debian.org']
255         }
256
257         file { '/usr/local/bin/check_for_updates':
258                 source => 'puppet:///modules/debian_org/check_for_updates',
259                 mode   => '0755',
260                 owner  => root,
261                 group  => root,
262         }
263         file { '/usr/local/bin/dsa-is-shutdown-scheduled':
264                 source  => 'puppet:///modules/debian_org/dsa-is-shutdown-scheduled',
265                 mode    => '0555',
266         }
267
268         exec { 'dpkg-reconfigure tzdata -pcritical -fnoninteractive':
269                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
270                 refreshonly => true
271         }
272         exec { 'service puppetmaster restart':
273                 refreshonly => true
274         }
275         exec { 'service rc.local restart':
276                 refreshonly => true
277         }
278         exec { 'init q':
279                 refreshonly => true
280         }
281
282         exec { 'systemctl daemon-reload':
283                 refreshonly => true,
284                 onlyif  => "test -x /bin/systemctl"
285         }
286
287         exec { 'systemd-tmpfiles --create --exclude-prefix=/dev':
288                 refreshonly => true,
289                 onlyif  => "test -x /bin/systemd-tmpfiles"
290         }
291
292         tidy { '/var/lib/puppet/clientbucket/':
293                 age      => '2w',
294                 recurse  => 9,
295                 type     => ctime,
296                 matches  => [ 'paths', 'contents' ],
297                 schedule => weekly
298         }
299
300         file { '/root/.bashrc':
301                 source => 'puppet:///modules/debian_org/root-dotfiles/bashrc',
302         }
303         file { '/root/.profile':
304                 source => 'puppet:///modules/debian_org/root-dotfiles/profile',
305         }
306         file { '/root/.selected_editor':
307                 source => 'puppet:///modules/debian_org/root-dotfiles/selected_editor',
308         }
309         file { '/root/.screenrc':
310                 source => 'puppet:///modules/debian_org/root-dotfiles/screenrc',
311         }
312         file { '/root/.tmux.conf':
313                 source => 'puppet:///modules/debian_org/root-dotfiles/tmux.conf',
314         }
315         file { '/root/.vimrc':
316                 source => 'puppet:///modules/debian_org/root-dotfiles/vimrc',
317         }
318
319         if versioncmp($::lsbmajdistrelease, '9') >= 0 { # older puppets do facts as strings.
320                 if $::processorcount > 1 {
321                         package { 'irqbalance': ensure => installed }
322                 }
323         }
324 }