From 3911c1b7bd444758a4eca30b522ac48977a5e51e Mon Sep 17 00:00:00 2001 From: Vadym Chepkov Date: Tue, 20 Aug 2024 11:34:56 -0400 Subject: [PATCH] fix: limit scope of update-bls-cmdline to RHEL9 grub2 on Amazon/Fedora is not compatible Co-authored-by: Vadym Chepkov Co-authored-by: Ewoud Kohl van Wijngaarden --- lib/puppet/provider/kernel_parameter/grub2.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/puppet/provider/kernel_parameter/grub2.rb b/lib/puppet/provider/kernel_parameter/grub2.rb index a3b5046..1af70ea 100644 --- a/lib/puppet/provider/kernel_parameter/grub2.rb +++ b/lib/puppet/provider/kernel_parameter/grub2.rb @@ -35,19 +35,15 @@ def self.mkconfig_path # # @return (String) The commandline def self.mkconfig_cmdline - 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 + os = Facter.value(:os) + # BLS cmdline option is only needed on RHEL 9.3+ + # Fedora and Amazon Linux lack support and are excluded + # since they don't have a release with major version 9 + needs_bls_cmdline = os.is_a?(Hash) && os['family'] == 'RedHat' && + os['release']['major'].to_i == 9 && os['release']['minor'].to_i >= 3 cmdline = [mkconfig_path] - cmdline << '--update-bls-cmdline' if needs_bls_cmdline.call + cmdline << '--update-bls-cmdline' if needs_bls_cmdline cmdline end