Defined Type: grub::bootparam

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

Overview

Parameters:

  • ensure (Any) (defaults to: present)
  • mode (Any) (defaults to: 'keyvalue')
  • key (Any) (defaults to: $title)
  • value (Any) (defaults to: undef)
  • glob (Any) (defaults to: true)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'modules/grub/manifests/bootparam.pp', line 41

define grub::bootparam(
  $ensure=present,
  $mode='keyvalue',
  $key=$title,
  $value=undef,
  $glob=true,
) {
    include grub

    # Logical sanity contraints:
    if $mode == 'keyvalue' {
        if $ensure == 'present' and $value == undef {
            fail('Cannot set an undefined value in keyvalue mode')
        }
    }
    elsif $value != undef {
        fail('Cannot set a value in non-keyvalue mode')
    }

    $param = $value ? {
        undef   => $key,
        default => "${key}=${value}",
    }

    if $mode != 'keyvalue' or !$glob {
        $change = $ensure ? {
            'present' => "set GRUB_CMDLINE_LINUX/value[. = \"${param}\"] ${param}",
            'absent'  => "rm GRUB_CMDLINE_LINUX/value[. = \"${param}\"]",
        }
    } else {
        $change = $ensure ? {
            'present' => "set GRUB_CMDLINE_LINUX/value[. =~ glob(\"${key}=*\")] ${param}",
            'absent'  => "rm GRUB_CMDLINE_LINUX/value[. =~ glob(\"${key}=*\")]",
        }
    }

    augeas { "grub2 ${param}":
        incl    => '/etc/default/grub',
        lens    => 'Shellvars_list.lns',
        changes => [
            $change,
        ],
        notify  => Exec['update-grub'],
    }
}