From 6f11d078b6d088dcb4190d88df00abaab2581a44 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Tue, 9 Jul 2024 11:52:47 -0500 Subject: [PATCH 1/2] Update BLS kernel options on EL >= 9.3 Fixes #95 --- lib/puppet/provider/kernel_parameter/grub2.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/kernel_parameter/grub2.rb b/lib/puppet/provider/kernel_parameter/grub2.rb index b7d9c25..308abed 100644 --- a/lib/puppet/provider/kernel_parameter/grub2.rb +++ b/lib/puppet/provider/kernel_parameter/grub2.rb @@ -31,8 +31,21 @@ def self.mkconfig_path confine exists: mkconfig_path, for_binary: true + # Add BLS specific option to mkconfig command if needed + # + # @return (String) The commandline + def self.mkconfig_cmdline + cmdline = [self.mkconfig_path] + if ((Facter.value(:os) && Facter.value(:os)['family']) == 'RedHat') + if ((Facter.value(:os)['release']['major'].to_i == 9) && (Facter.value(:os)['release']['minor'].to_i >= 3)) || (Facter.value(:os)['release']['major'].to_i > 9) + cmdline = cmdline.append("--update-bls-cmdline") + end + end + cmdline + end + def mkconfig - execute(self.class.mkconfig_path, { failonfail: true, combine: false }) + execute(self.class.mkconfig_cmdline, { failonfail: true, combine: false }) end # when both grub* providers match, prefer GRUB 2 From ebbe9c662206369cda97ce2ff2b644d3624c89f3 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Tue, 9 Jul 2024 13:08:34 -0500 Subject: [PATCH 2/2] Refactor for rubocop --- lib/puppet/provider/kernel_parameter/grub2.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/kernel_parameter/grub2.rb b/lib/puppet/provider/kernel_parameter/grub2.rb index 308abed..a3b5046 100644 --- a/lib/puppet/provider/kernel_parameter/grub2.rb +++ b/lib/puppet/provider/kernel_parameter/grub2.rb @@ -35,12 +35,19 @@ def self.mkconfig_path # # @return (String) The commandline def self.mkconfig_cmdline - cmdline = [self.mkconfig_path] - if ((Facter.value(:os) && Facter.value(:os)['family']) == 'RedHat') - if ((Facter.value(:os)['release']['major'].to_i == 9) && (Facter.value(:os)['release']['minor'].to_i >= 3)) || (Facter.value(:os)['release']['major'].to_i > 9) - cmdline = cmdline.append("--update-bls-cmdline") - end + needs_bls_cmdline = lambda do + os = Facter.value(:os) + return false unless os.is_a?(Hash) + + return false unless os['family'] == 'RedHat' + return false if os['release']['major'].to_i < 9 + return false if os['release']['major'].to_i == 9 && os['release']['minor'].to_i < 3 + + true end + + cmdline = [mkconfig_path] + cmdline << '--update-bls-cmdline' if needs_bls_cmdline.call cmdline end