37778d12279cd47b97f706408e00788dcb007a4f
[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                 if ($::debarchitecture != 'ppc64el') {
7                         $grub_do_kernel_serial = true
8                         $grub_do_grub_serial = true
9                 }
10         } 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] {
11                 $grub_manage = true
12                 $grub_do_kernel_serial = true
13                 $grub_do_grub_serial = true
14         } elsif $::hostname in [mirror-skroutz,conova-node01,conova-node02,arm-arm-01,fasolo,manda-node03,manda-node04,schmelzer,smit] {
15                 $grub_manage = true
16                 $grub_do_kernel_serial = true
17                 $grub_do_grub_serial = true
18         } elsif $::hostname in [arm-arm-03] {
19                 $grub_manage = true
20                 $grub_do_kernel_serial = true
21                 $grub_do_grub_serial = false
22         #} elsif $::hostname in [villa] {
23         #       $grub_manage = true
24         #       $grub_do_kernel_serial = false
25         #       $grub_do_grub_serial = false
26         } else {
27                 $grub_manage = false
28         }
29
30         if ($::update_grub and $grub_manage) {
31                 # hp-health requires nopat on linux 4.9
32                 $grub_do_nopat = ($::systemproductname and $::systemproductname =~ /^ProLiant/ and versioncmp($::kernelversion, '4.9') >= 0)
33
34                 $grub_do_pti_on = ($::debarchitecture == 'amd64' and versioncmp($::lsbmajdistrelease, '9') >= 0)
35
36                 $grub_do_extra = $::hostname in [fasolo,grnet-node01,grnet-node02]
37
38                 file { '/etc/default/grub':
39                         # restore to default
40                         source => 'puppet:///modules/grub/etc-default-grub',
41                         notify  => Exec['update-grub']
42                 }
43
44                 file { '/etc/default/grub.d':
45                         ensure => directory,
46                         mode   => '0555',
47                         purge   => true,
48                         force   => true,
49                         recurse => true,
50                         source  => 'puppet:///files/empty/',
51                 }
52
53                 file { '/etc/default/grub.d/puppet-grub-serial.cfg':
54                         ensure => $grub_do_kernel_serial ? { true  => 'present', default => 'absent' },
55                         content  => template('grub/puppet-grub-serial.cfg.erb'),
56                         notify  => Exec['update-grub']
57                 }
58
59                 file { '/etc/default/grub.d/puppet-kernel-serial.cfg':
60                         ensure => $grub_do_grub_serial ? { true  => 'present', default => 'absent' },
61                         content  => template('grub/puppet-kernel-serial.cfg.erb'),
62                         notify  => Exec['update-grub']
63                 }
64
65                 file { '/etc/default/grub.d/puppet-net-ifnames.cfg':
66                         ensure => $grub_do_ifnames ? { true  => 'present', default => 'absent' },
67                         content  => template('grub/puppet-net-ifnames.cfg.erb'),
68                         notify  => Exec['update-grub']
69                 }
70
71                 file { '/etc/default/grub.d/puppet-kernel-nopat.cfg':
72                         ensure => $grub_do_nopat ? { true  => 'present', default => 'absent' },
73                         content  => template('grub/puppet-kernel-nopat.cfg.erb'),
74                         notify  => Exec['update-grub']
75                 }
76
77                 file { '/etc/default/grub.d/puppet-kernel-extra.cfg':
78                         ensure => $grub_do_extra ? { true  => 'present', default => 'absent' },
79                         content  => template('grub/puppet-kernel-extra.cfg.erb'),
80                         notify  => Exec['update-grub']
81                 }
82
83                 file { '/etc/default/grub.d/puppet-kernel-pti-on.cfg':
84                         ensure => $grub_do_pti_on ? { true  => 'present', default => 'absent' },
85                         content  => template('grub/puppet-kernel-pti-on.cfg.erb'),
86                         notify  => Exec['update-grub']
87                 }
88         }
89
90         exec { 'update-grub':
91                 refreshonly => true,
92                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
93         }
94 }