diff --git a/lib/puppet/provider/grub_config/grub2.rb b/lib/puppet/provider/grub_config/grub2.rb index 4879699..ea1cdcc 100644 --- a/lib/puppet/provider/grub_config/grub2.rb +++ b/lib/puppet/provider/grub_config/grub2.rb @@ -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 diff --git a/lib/puppet/provider/grub_menuentry/grub2.rb b/lib/puppet/provider/grub_menuentry/grub2.rb index 319bc7b..d29a265 100644 --- a/lib/puppet/provider/grub_menuentry/grub2.rb +++ b/lib/puppet/provider/grub_menuentry/grub2.rb @@ -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 diff --git a/lib/puppet/provider/grub_user/grub2.rb b/lib/puppet/provider/grub_user/grub2.rb index 000da66..f1f5b9e 100644 --- a/lib/puppet/provider/grub_user/grub2.rb +++ b/lib/puppet/provider/grub_user/grub2.rb @@ -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 diff --git a/lib/puppet/provider/kernel_parameter/grub2.rb b/lib/puppet/provider/kernel_parameter/grub2.rb index c07ecce..b6f4407 100644 --- a/lib/puppet/provider/kernel_parameter/grub2.rb +++ b/lib/puppet/provider/kernel_parameter/grub2.rb @@ -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 diff --git a/lib/puppet/type/grub_user.rb b/lib/puppet/type/grub_user.rb index 4acdeb6..916ffac 100644 --- a/lib/puppet/type/grub_user.rb +++ b/lib/puppet/type/grub_user.rb @@ -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. diff --git a/lib/puppet/type/kernel_parameter.rb b/lib/puppet/type/kernel_parameter.rb index 3ec6cd9..bfa301e 100644 --- a/lib/puppet/type/kernel_parameter.rb +++ b/lib/puppet/type/kernel_parameter.rb @@ -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 diff --git a/spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb b/spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb index 5964c1c..95ab8a3 100755 --- a/spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb +++ b/spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb @@ -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",