Skip to content

Commit

Permalink
Fix so /boot/efi/EFI/redhat/grub.cfg is not updated when EL > 9
Browse files Browse the repository at this point in the history
  • Loading branch information
hbarina committed Dec 20, 2024
1 parent 5b9a85c commit ed4b9a6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/puppetx/augeasproviders_grub/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ def self.os_name
''
end

# Return true if we want to include /boot/efi/EFI/#{os_name}/grub.cfg
# in being updated with grub2_mkconfig. To keep behavior same: true if
# family is not redhat or EL < 9.
# In other places in this file, os_name should really be family, but I
# am not experiencing any issues with OracleLinux, and don't have other
# linux's to test, so will leave it.
# @return (Boolean)
def self.el_lt_9

Check failure on line 141 in lib/puppetx/augeasproviders_grub/util.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Naming/VariableNumber: Use normalcase for method name numbers. (https://rubystyle.guide#snake-case-symbols-methods-vars-with-numbers)
major = Facter.value(:os).dig('release','major') || 0

Check failure on line 142 in lib/puppetx/augeasproviders_grub/util.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Layout/SpaceAfterComma: Space missing after comma. (https://rubystyle.guide#spaces-operators)
family = Facter.value(:os).dig('family').downcase || ''

Check failure on line 143 in lib/puppetx/augeasproviders_grub/util.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Style/SingleArgumentDig: Use `Facter.value(:os)['family']` instead of `Facter.value(:os).dig('family')`.
(family !~/redhat/) or (major.to_i < 9)

Check failure on line 144 in lib/puppetx/augeasproviders_grub/util.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Layout/SpaceAroundOperators: Surrounding space missing for operator `!~`. (https://rubystyle.guide#spaces-operators)

Check failure on line 144 in lib/puppetx/augeasproviders_grub/util.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Style/RegexpLiteral: Use `%r` around regular expression. (https://rubystyle.guide#percent-r)
end

# Return the location of all valid GRUB2 configurations on the system.
#
# @raise (Puppet::Error) if no path is found
Expand All @@ -140,11 +153,12 @@ def self.grub2_cfg_paths
paths = [
'/etc/grub2.cfg',
'/etc/grub2-efi.cfg',
"/boot/efi/EFI/#{os_name.downcase}/grub.cfg",
'/boot/grub2/grub.cfg',
'/boot/grub/grub.cfg'
]

paths << "/boot/efi/EFI/#{os_name.downcase}/grub.cfg" if el_lt_9

valid_paths = paths.map do |path|
real_path = File.realpath(path)
real_path if File.readable?(real_path) && !File.directory?(real_path)
Expand Down

0 comments on commit ed4b9a6

Please sign in to comment.