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