Put grub and kernel on ttyS0 on manda-node0[34]
[mirror/dsa-puppet.git] / modules / grub / manifests / init.pp
1 class grub {
2         $grub_do_ifnames = ($::kernel == 'Linux' and $::is_virtual and $::virtual == 'kvm')
3
4         if ($::kernel == 'Linux' and $::is_virtual and $::virtual == 'kvm') {
5                 $grub_manage = true
6                 $grub_do_kernel_serial = true
7                 $grub_do_grub_serial = true
8         } elsif $::hostname in [ubc-enc2bl01,ubc-enc2bl02,ubc-enc2bl09,ubc-enc2bl10,casulana,mirror-anu,sallinen,storace,mirror-accumu,bm-bl1,bm-bl2,bm-bl3,bm-bl4,bm-bl5,bm-bl6,bm-bl7,bm-bl8,bm-bl9,bm-bl10,bm-bl11,bm-bl12,bm-bl13,bm-bl14,grnet-node01,grnet-node02,csail-node01,csail-node02,byrd,mirror-isc,mirror-umn,lobos,villa,klecker,clementi,czerny,lw01,lw02,lw03,lw04,lw07,lw08,lw09,lw10] {
9                 $grub_manage = true
10                 $grub_do_kernel_serial = true
11                 $grub_do_grub_serial = true
12         } elsif $::hostname in [mirror-skroutz,conova-node01,conova-node02,arm-arm-01,fasolo,manda-node03,manda-node04] {
13                 $grub_manage = true
14                 $grub_do_kernel_serial = true
15                 $grub_do_grub_serial = true
16         } elsif $::hostname in [arm-arm-03] {
17                 $grub_manage = true
18                 $grub_do_kernel_serial = true
19                 $grub_do_grub_serial = false
20         #} elsif $::hostname in [villa] {
21         #       $grub_manage = true
22         #       $grub_do_kernel_serial = false
23         #       $grub_do_grub_serial = false
24         } else {
25                 $grub_manage = false
26         }
27
28         if ($::update_grub and $grub_manage) {
29                 # hp-health requires nopat on linux 4.9
30                 $grub_do_nopat = ($::systemproductname and $::systemproductname =~ /^ProLiant/ and versioncmp($::kernelversion, '4.9') >= 0)
31
32                 $grub_do_pti_on = ($::debarchitecture == 'amd64' and versioncmp($::lsbmajdistrelease, '9') >= 0)
33
34                 $grub_do_extra = $::hostname in [fasolo,grnet-node01,grnet-node02]
35
36                 file { '/etc/default/grub':
37                         # restore to default
38                         source => 'puppet:///modules/grub/etc-default-grub',
39                         notify  => Exec['update-grub']
40                 }
41
42                 file { '/etc/default/grub.d':
43                         ensure => directory,
44                         mode   => '0555',
45                         purge   => true,
46                         force   => true,
47                         recurse => true,
48                         source  => 'puppet:///files/empty/',
49                 }
50
51                 file { '/etc/default/grub.d/puppet-grub-serial.cfg':
52                         ensure => $grub_do_kernel_serial ? { true  => 'present', default => 'absent' },
53                         content  => template('grub/puppet-grub-serial.cfg.erb'),
54                         notify  => Exec['update-grub']
55                 }
56
57                 file { '/etc/default/grub.d/puppet-kernel-serial.cfg':
58                         ensure => $grub_do_grub_serial ? { true  => 'present', default => 'absent' },
59                         content  => template('grub/puppet-kernel-serial.cfg.erb'),
60                         notify  => Exec['update-grub']
61                 }
62
63                 file { '/etc/default/grub.d/puppet-net-ifnames.cfg':
64                         ensure => $grub_do_ifnames ? { true  => 'present', default => 'absent' },
65                         content  => template('grub/puppet-net-ifnames.cfg.erb'),
66                         notify  => Exec['update-grub']
67                 }
68
69                 file { '/etc/default/grub.d/puppet-kernel-nopat.cfg':
70                         ensure => $grub_do_nopat ? { true  => 'present', default => 'absent' },
71                         content  => template('grub/puppet-kernel-nopat.cfg.erb'),
72                         notify  => Exec['update-grub']
73                 }
74
75                 file { '/etc/default/grub.d/puppet-kernel-extra.cfg':
76                         ensure => $grub_do_extra ? { true  => 'present', default => 'absent' },
77                         content  => template('grub/puppet-kernel-extra.cfg.erb'),
78                         notify  => Exec['update-grub']
79                 }
80
81                 file { '/etc/default/grub.d/puppet-kernel-pti-on.cfg':
82                         ensure => $grub_do_pti_on ? { true  => 'present', default => 'absent' },
83                         content  => template('grub/puppet-kernel-pti-on.cfg.erb'),
84                         notify  => Exec['update-grub']
85                 }
86         }
87
88         exec { 'update-grub':
89                 refreshonly => true,
90                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
91         }
92 }