Skip to content

Commit

Permalink
attempt at deleting entries from both sections
Browse files Browse the repository at this point in the history
  • Loading branch information
kenyon committed Nov 26, 2020
1 parent 0ef64af commit 53b9b43
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/puppet/provider/kernel_parameter/grub2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ def create
self.value=(resource[:value])
end

def destroy
augopen! do |aug|
aug.rm("$target/GRUB_CMDLINE_LINUX_DEFAULT/value[.=~regexp('^#{resource[:name]}(=.*)?$')]")
aug.rm("$target/GRUB_CMDLINE_LINUX/value[.=~regexp('^#{resource[:name]}(=.*)?$')]")
end
end

def value
augopen do |aug|
aug.match('$resource').map {|vp|
Expand Down
26 changes: 26 additions & 0 deletions spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,32 @@
')
end

it "should delete entries from GRUB_CMDLINE_LINUX_DEFAULT with bootmode all" do
provider_class.any_instance.expects(:mkconfig).with("-o", "/boot/grub2/grub.cfg")
provider_class.any_instance.expects(:mkconfig).with("-o", "/etc/grub2-efi.cfg")

apply!(Puppet::Type.type(:kernel_parameter).new(
:name => "rhgb",
:ensure => "absent",
:bootmode => :all,
:target => target,
:provider => "grub2"
))

augparse_filter(target, LENS, FILTER, '
{ "GRUB_CMDLINE_LINUX"
{ "quote" = "\"" }
{ "value" = "quiet" }
{ "value" = "elevator=noop" }
{ "value" = "divider=10" }
}
{ "GRUB_CMDLINE_LINUX_DEFAULT"
{ "quote" = "\"" }
{ "value" = "nohz=on" }
}
')
end

describe "when modifying values" do
before :each do
provider_class.any_instance.stubs(:create).never
Expand Down

0 comments on commit 53b9b43

Please sign in to comment.