]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/debian-org/manifests/init.pp
Add jessie-proposed-update repo for all Loongson 3 machines
[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 [mips-aql-05, mipsel-aql-01, mipsel-aql-02, mipsel-manda-02, eberlin, etler]) {
166                 site::aptrepo { 'proposed-updates':
167                         url        => $mirror,
168                         suite      => "${::lsbdistcodename}-proposed-updates",
169                         components => ['main','contrib','non-free']
170                 }
171         } else {
172                 site::aptrepo { 'proposed-updates':
173                         ensure => absent,
174                 }
175         }
176
177         site::aptrepo { 'debian.org':
178                 ensure => absent,
179         }
180
181         site::aptrepo { 'db.debian.org':
182                 url        => 'http://db.debian.org/debian-admin',
183                 suite      => 'debian-all',
184                 components => 'main',
185                 key        => 'puppet:///modules/debian-org/db.debian.org.gpg',
186         }
187         site::aptrepo { 'db.debian.org-suite':
188                 url        => 'http://db.debian.org/debian-admin',
189                 suite      => $::lsbdistcodename,
190                 components => 'main',
191         }
192
193         augeas { 'inittab_replicate':
194                 context => '/files/etc/inittab',
195                 changes => [
196                         'set ud/runlevels 2345',
197                         'set ud/action respawn',
198                         'set ud/process "/usr/bin/ud-replicated -d"',
199                 ],
200                 notify  => Exec['init q'],
201         }
202
203         if getfromhash($site::nodeinfo, 'hoster', 'mirror-debian') {
204                 site::aptrepo { 'debian':
205                         url        => getfromhash($site::nodeinfo, 'hoster', 'mirror-debian'),
206                         suite      => $mungedcodename,
207                         components => ['main','contrib','non-free']
208                 }
209         }
210
211         file { '/etc/facter':
212                 ensure  => directory,
213                 purge   => true,
214                 force   => true,
215                 recurse => true,
216                 source  => 'puppet:///files/empty/',
217         }
218         file { '/etc/facter/facts.d':
219                 ensure => directory,
220         }
221         file { '/etc/facter/facts.d/debian_facts.yaml':
222                 content => template('debian-org/debian_facts.yaml.erb')
223         }
224         file { '/etc/apt/preferences':
225                 source => 'puppet:///modules/debian-org/apt.preferences',
226         }
227         file { '/etc/apt/apt.conf.d/local-compression':
228                 source => 'puppet:///modules/debian-org/apt.conf.d/local-compression',
229         }
230         file { '/etc/apt/apt.conf.d/local-recommends':
231                 source => 'puppet:///modules/debian-org/apt.conf.d/local-recommends',
232         }
233         file { '/etc/apt/apt.conf.d/local-pdiffs':
234                 source => 'puppet:///modules/debian-org/apt.conf.d/local-pdiffs',
235         }
236         file { '/etc/timezone':
237                 source => 'puppet:///modules/debian-org/timezone',
238                 notify => Exec['dpkg-reconfigure tzdata -pcritical -fnoninteractive'],
239         }
240         if $::hostname == handel {
241                 include puppetmaster::db
242                 $dbpassword = $puppetmaster::db::password
243         }
244         file { '/etc/puppet/puppet.conf':
245                 content => template('debian-org/puppet.conf.erb'),
246         }
247         file { '/etc/default/puppet':
248                 source => 'puppet:///modules/debian-org/puppet.default',
249         }
250         file { '/etc/systemd':
251                 ensure  => directory,
252                 mode => 0755,
253         }
254         file { '/etc/systemd/system':
255                 ensure  => directory,
256                 mode => 0755,
257         }
258         file { '/etc/systemd/system/ud-replicated.service':
259                 ensure => $servicefiles,
260                 source => 'puppet:///modules/debian-org/ud-replicated.service',
261                 notify => Exec['systemctl daemon-reload'],
262         }
263         if $systemd {
264                 file { '/etc/systemd/system/multi-user.target.wants/ud-replicated.service':
265                         ensure => 'link',
266                         target => '../ud-replicated.service',
267                         notify => Exec['systemctl daemon-reload'],
268                 }
269         }
270         file { '/etc/systemd/system/puppet.service':
271                 ensure => 'link',
272                 target => '/dev/null',
273                 notify => Exec['systemctl daemon-reload'],
274         }
275
276         file { '/etc/cron.d/dsa-puppet-stuff':
277                 content => template('debian-org/dsa-puppet-stuff.cron.erb'),
278                 require => Package['debian.org'],
279         }
280         file { '/etc/ldap/ldap.conf':
281                 require => Package['debian.org'],
282                 content  => template('debian-org/ldap.conf.erb'),
283         }
284         file { '/etc/pam.d/common-session':
285                 require => Package['debian.org'],
286                 content => template('debian-org/pam.common-session.erb'),
287         }
288         file { '/etc/pam.d/common-session-noninteractive':
289                 require => Package['debian.org'],
290                 content => template('debian-org/pam.common-session-noninteractive.erb'),
291         }
292         file { '/etc/rc.local':
293                 mode   => '0755',
294                 content => template('debian-org/rc.local.erb'),
295                 notify => Exec['service rc.local start'],
296         }
297         file { '/etc/dsa':
298                 ensure => directory,
299                 mode   => '0755',
300         }
301         file { '/etc/dsa/cron.ignore.dsa-puppet-stuff':
302                 source  => 'puppet:///modules/debian-org/dsa-puppet-stuff.cron.ignore',
303                 require => Package['debian.org']
304         }
305         file { '/etc/nsswitch.conf':
306                 mode   => '0755',
307                 source => 'puppet:///modules/debian-org/nsswitch.conf',
308         }
309
310         # set mmap_min_addr to 4096 to mitigate
311         # Linux NULL-pointer dereference exploits
312         site::sysctl { 'mmap_min_addr':
313                 ensure => absent
314         }
315         site::sysctl { 'perf_event_paranoid':
316                 key   => 'kernel.perf_event_paranoid',
317                 value => '2',
318         }
319         site::alternative { 'editor':
320                 linkto => '/usr/bin/vim.basic',
321         }
322         site::alternative { 'view':
323                 linkto => '/usr/bin/vim.basic',
324         }
325         mailalias { 'samhain-reports':
326                 ensure    => present,
327                 recipient => $debianadmin,
328                 require   => Package['debian.org']
329         }
330
331         file { '/usr/local/bin/check_for_updates':
332                 source => 'puppet:///modules/debian-org/check_for_updates',
333                 mode   => '0755',
334                 owner  => root,
335                 group  => root,
336         }
337
338         exec { 'apt-get update':
339                 path    => '/usr/bin:/usr/sbin:/bin:/sbin',
340                 onlyif  => '/usr/local/bin/check_for_updates',
341                 require => File['/usr/local/bin/check_for_updates']
342         }
343         Exec['apt-get update']->Package<| tag == extra_repo |>
344
345         exec { 'dpkg-reconfigure tzdata -pcritical -fnoninteractive':
346                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
347                 refreshonly => true
348         }
349         exec { 'service puppetmaster restart':
350                 refreshonly => true
351         }
352         exec { 'service rc.local start':
353                 refreshonly => true
354         }
355         exec { 'init q':
356                 refreshonly => true
357         }
358
359         exec { 'systemctl daemon-reload':
360                 refreshonly => true,
361                 onlyif  => "test -x /bin/systemctl"
362         }
363
364         exec { 'systemd-tmpfiles --create --exclude-prefix=/dev':
365                 refreshonly => true,
366                 onlyif  => "test -x /bin/systemd-tmpfiles"
367         }
368
369         tidy { '/var/lib/puppet/clientbucket/':
370                 age      => '2w',
371                 recurse  => 9,
372                 type     => ctime,
373                 matches  => [ 'paths', 'contents' ],
374                 schedule => weekly
375         }
376
377         file { '/root/.bashrc':
378                 source => 'puppet:///modules/debian-org/root-dotfiles/bashrc',
379         }
380         file { '/root/.profile':
381                 source => 'puppet:///modules/debian-org/root-dotfiles/profile',
382         }
383         file { '/root/.screenrc':
384                 source => 'puppet:///modules/debian-org/root-dotfiles/screenrc',
385         }
386         file { '/root/.vimrc':
387                 source => 'puppet:///modules/debian-org/root-dotfiles/vimrc',
388         }
389 }