Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new parameter to prevent grub-mkconfig being run #59

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/puppet/provider/grub_config/grub2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def flush
fail("Cannot find grub.cfg location to use with grub-mkconfig") unless cfg

super
mkconfig "-o", cfg

mkconfig "-o", cfg if resource[:run_mkconfig]
end
end
2 changes: 1 addition & 1 deletion lib/puppet/provider/grub_menuentry/grub2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def flush
FileUtils.rm_f(legacy_target)

# Need to rebuild the full grub config if we removed a legacy target
grub2_mkconfig
grub2_mkconfig if resource[:run_mkconfig]
end
end
else
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/grub_user/grub2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def flush
FileUtils.chmod(0755, resource[:target])
end

mkconfig "-o", grub2_cfg_path
mkconfig "-o", grub2_cfg_path if resource[:run_mkconfig]
end

private
Expand Down
9 changes: 6 additions & 3 deletions lib/puppet/provider/kernel_parameter/grub2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ def flush
fail("Cannot find grub.cfg location to use with grub-mkconfig") unless cfg

super
cfg.each {|c|
mkconfig "-o", c
}

if resource[:run_mkconfig]
cfg.each {|c|
mkconfig "-o", c
}
end
end
end
7 changes: 7 additions & 0 deletions lib/puppet/type/grub_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@
end
end

newparam(:run_mkconfig, :boolean => true) do
desc "Whether grub(2)-mkconfig should be ran after updating the GRUB configuration"

newvalues(:true, :false)
defaultto(:true)
end

newproperty(:purge, :boolean => true) do
desc <<-EOM
Purge all unmanaged users.
Expand Down
7 changes: 7 additions & 0 deletions lib/puppet/type/kernel_parameter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
defaultto :all
end

newparam(:run_mkconfig, :boolean => true) do
desc "Whether grub(2)-mkconfig should be ran after updating the GRUB configuration"

newvalues(:true, :false)
defaultto(:true)
end

autorequire(:file) do
self[:target]
end
Expand Down
28 changes: 28 additions & 0 deletions spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,34 @@
provider_class.any_instance.expects(:mkconfig).with("-o", "/etc/grub2-efi.cfg")
end

it "should not run mkconfig if run_mkconfig is false" do
provider_class.any_instance.expects(:mkconfig).never
provider_class.any_instance.expects(:mkconfig).never

apply!(Puppet::Type.type(:kernel_parameter).new(
:name => "foo",
:ensure => :present,
:target => target,
:provider => "grub2",
:run_mkconfig => false
))

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

it "should create no-value entries" do
apply!(Puppet::Type.type(:kernel_parameter).new(
:name => "foo",
Expand Down