Skip to content
Snippets Groups Projects
Commit c25ee385 authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Add support for Grub 2 in kernel_option.

This adds a new helper for bootloader::kernel_option handling the
Grub 2 case.  This also only supports removing options, though, not
setting them.
parent bc533771
No related branches found
No related tags found
No related merge requests found
# Copyright © 2017 Thomas Bellman, Linköping, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
/*
* Internal helper for the bootloader::kernel_option definition.
*/
define bootloader::grub2::kernel_option($ensure, $value)
{
include bootloader::grub2::rebuild_grub_cfg
$prefix = '^(GRUB_CMDLINE_LINUX="?(|.*\s))'
$suffix = '((|\s.*)("?))\s*$'
$qname = regexp_quote($name)
if ($ensure == 'absent')
{
regexp_replace_lines {
"bootloader::grub2::kernel_option::${name}":
file => '/etc/default/grub',
pattern => "${prefix}${qname}(=[^ \t\"]*)?${suffix}",
replacement => '\1\4',
notify => Class['bootloader::grub2::rebuild_grub_cfg'];
}
}
elsif ($ensure != 'present')
{
fail("Bootloader::Grub2::Kernel_Option[${title}]: ",
"Bad ensure parameter, ${ensure}")
}
elsif ($value == true or $value == false)
{
# Detecting if the option is already present is not easily done
# using regexps...
fail("Bootloader::Grub2::Kernel_option[${title}]: ",
"Setting a kernel option is not yet implemented.")
}
else
{
# Detecting if the option is already present is not easily done
# using regexps...
fail("Bootloader::Grub2::Kernel_option[${title}]: ",
"Setting a kernel option is not yet implemented.")
}
}
......@@ -34,6 +34,12 @@ define bootloader::kernel_option($ensure='present', $value=undef)
name => $name, ensure => $ensure, value => $value;
}
}
'grub2': {
bootloader::grub2::kernel_option {
$title:
name => $name, ensure => $ensure, value => $value;
}
}
default: {
fail("Bootloader::Kernel_option[${title}]: ",
"Unsupported bootloader, ${bootloader}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment