puppetized grub on mirror-skroutz, mirror-accumu
[mirror/dsa-puppet.git] / modules / grub / manifests / init.pp
1 class grub {
2         if ($::kernel == 'Linux' and $::is_virtual and $::virtual == 'kvm') {
3                 $grub_manage = true
4                 $grub_do_serial = true
5                 $grub_do_ifnames = true
6         } elsif $::hostname in [ubc-enc2bl01,ubc-enc2bl02,ubc-enc2bl09,ubc-enc2bl10,casulana,mirror-anu,sallinen,storace,mirror-skroutz] {
7                 $grub_manage = true
8                 $grub_do_serial = true
9                 $grub_do_nopat = true
10         } elsif $::hostname in [mirror-accumu] {
11                 $grub_manage = true
12                 $grub_do_serial = true
13                 $grub_do_nopat = true
14         } else {
15                 $grub_manage = false
16         }
17
18
19         if $grub_manage {
20                 file { '/etc/default/grub':
21                         # restore to default
22                         source => 'puppet:///modules/grub/etc-default-grub',
23                         notify  => Exec['update-grub']
24                 }
25
26                 file { '/etc/default/grub.d':
27                         ensure => directory
28                 }
29
30                 file { '/etc/default/grub.d/puppet-grub-serial.cfg':
31                         ensure => $grub_do_serial ? { true  => 'present', default => 'absent' },
32                         content  => template('grub/puppet-grub-serial.cfg.erb'),
33                         notify  => Exec['update-grub']
34                 }
35
36                 file { '/etc/default/grub.d/puppet-net-ifnames.cfg':
37                         ensure => $grub_do_ifnames ? { true  => 'present', default => 'absent' },
38                         content  => template('grub/puppet-net-ifnames.cfg.erb'),
39                         notify  => Exec['update-grub']
40                 }
41
42                 file { '/etc/default/grub.d/puppet-kernel-nopat.cfg':
43                         ensure => $grub_do_nopat ? { true  => 'present', default => 'absent' },
44                         content  => template('grub/puppet-kernel-nopat.cfg.erb'),
45                         notify  => Exec['update-grub']
46                 }
47         }
48
49         exec { 'update-grub':
50                 refreshonly => true,
51                 path        => '/usr/bin:/usr/sbin:/bin:/sbin',
52         }
53 }