Puppet Class: grub::defaults

Defined in:
modules/grub/manifests/defaults.pp

Overview



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'modules/grub/manifests/defaults.pp', line 14

class grub::defaults {
    include ::grub

    # The augeas Shellvars_list lens can't handle backticks for versions < 1.2
    # We fallback to the legacy grep/sed method in that case.
    if versioncmp($::augeasversion, '1.2.0') >= 0 {
        augeas { 'grub2':
            incl    => '/etc/default/grub',
            lens    => 'Shellvars_list.lns',
            changes => [
                # set terminal; default usually is just serial
                'set GRUB_TERMINAL/quote \'"\'',
                'set GRUB_TERMINAL/value[1] console',
                'set GRUB_TERMINAL/value[2] serial',
                # removes quiet, splash from default kopts
                'rm GRUB_CMDLINE_LINUX_DEFAULT/value[. = "quiet"]',
                'rm GRUB_CMDLINE_LINUX_DEFAULT/value[. = "splash"]',
            ],
            notify  => Exec['update-grub'],
        }
    } else {
        # Disable the 'quiet' kernel command line option so console messages
        # will be printed.
        exec { 'grub2 remove quiet':
            path    => '/bin:/usr/bin',
            command => "sed -r -i '/^GRUB_CMDLINE_LINUX_DEFAULT/s/quiet( splash)?//' /etc/default/grub",
            onlyif  => "grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=.*quiet( splash)?' /etc/default/grub",
            notify  => Exec['update-grub'],
        }

        # show the GRUB menu on both console & serial (default is serial)
        exec { 'grub2 terminal':
            path    => '/bin:/usr/bin',
            command => "sed -i '/^GRUB_TERMINAL/s/=.*/=\"console serial\"/' /etc/default/grub",
            unless  => "grep -q '^GRUB_TERMINAL=.*console serial' /etc/default/grub",
            onlyif  => 'test -f /etc/default/grub',
            notify  => Exec['update-grub'],
        }
    }
}