diff --git a/manifests/grub2/kernel_option.pp b/manifests/grub2/kernel_option.pp
index d0b13fd6871718c67ba117d98b209dc212f6171a..3b775d5706e3e15cc705d87180be3ac77a1b7ee9 100644
--- a/manifests/grub2/kernel_option.pp
+++ b/manifests/grub2/kernel_option.pp
@@ -1,4 +1,4 @@
-# Copyright © 2017   Thomas Bellman, Linköping, Sweden
+# Copyright © 2017-2022   Thomas Bellman, Linköping, Sweden
 # Licensed under the GNU LGPL v3+; see the README file for more information.
 
 
@@ -9,18 +9,20 @@ define bootloader::grub2::kernel_option($ensure, $value)
 {
     include bootloader::grub2::rebuild_grub_cfg
 
-    $prefix = '^(GRUB_CMDLINE_LINUX="?(|.*\s))'
-    $suffix = '((|\s.*)("?))\s*$'
+    $grub_defaults_file = '/etc/default/grub'
     $qname = regexp_quote($name)
+    # Augeas path expression to find nodes for the kernel parameter
+    $pathexpr = "GRUB_CMDLINE_LINUX/value[. =~ regexp('${qname}(=.*)?')]"
 
     if ($ensure == 'absent')
     {
-	regexp_replace_lines {
+	augeas {
 	    "bootloader::grub2::kernel_option::${name}":
-		file => '/etc/default/grub',
-		pattern => "${prefix}${qname}(=[^ \t\"]*)?${suffix}",
-		replacement => '\1\4',
-		notify => Class['bootloader::grub2::rebuild_grub_cfg'];
+		incl    => $grub_defaults_file,
+		lens    => 'Shellvars_list.lns',
+		context => "/files${grub_defaults_file}",
+		changes => "rm ${pathexpr}",
+		notify  => Class['bootloader::grub2::rebuild_grub_cfg'];
 	}
     }
     elsif ($ensure != 'present')
@@ -30,16 +32,24 @@ define bootloader::grub2::kernel_option($ensure, $value)
     }
     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.")
+	augeas {
+	    "bootloader::grub2::kernel_option::${name}":
+		incl    => $grub_defaults_file,
+		lens    => 'Shellvars_list.lns',
+		context => "/files${grub_defaults_file}",
+		changes => "set ${pathexpr} '${name}'",
+		notify  => Class['bootloader::grub2::rebuild_grub_cfg'];
+	}
     }
     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.")
+	augeas {
+	    "bootloader::grub2::kernel_option::${name}":
+		incl    => $grub_defaults_file,
+		lens    => 'Shellvars_list.lns',
+		context => "/files${grub_defaults_file}",
+		changes => "set ${pathexpr} '${name}=${value}'",
+		notify  => Class['bootloader::grub2::rebuild_grub_cfg'];
+	}
     }
 }
diff --git a/manifests/kernel_option.pp b/manifests/kernel_option.pp
index f2ba642c927b852b516df7d1d18a14dbdc292b4b..a610f21743fe6f888f040a4fb3bd65f1d9fe9c01 100644
--- a/manifests/kernel_option.pp
+++ b/manifests/kernel_option.pp
@@ -13,19 +13,15 @@
  *  - name	Kernel commandline option to set or remove.
  *
  *  - ensure	One of 'present' or 'absent'.
- *		Currently only 'absent' is implemented!
  *
  *  - value	The value to set the option to.  If set to true or false,
  *		it will be a "bare" option, i.e. something like "single".
  *		If a string, a valued option will be set, i.e. something
  *		like "console=ttyS0".
- *		Since only ensure => absent is implemented, the value
- *		parameter is currently ignored.
  *
  *  - provider	The bootloader in use.  Supported values are 'grub0' and
  *		'grub2'.  If not specified, the bootloader will be guessed
  *		based on the operating system.
- *		The grub2 provider currently only supports removing options.
  */
 define bootloader::kernel_option(
 	$ensure='present', $value=undef, $provider=undef)