diff --git a/lib/puppetx/augeasproviders_grub/util.rb b/lib/puppetx/augeasproviders_grub/util.rb index 6aa5156..f804ac8 100644 --- a/lib/puppetx/augeasproviders_grub/util.rb +++ b/lib/puppetx/augeasproviders_grub/util.rb @@ -150,12 +150,21 @@ def self.grub2_cfg_paths ] valid_paths = paths.map do |path| - begin + real_path = nil + + if File.readable?(path) && !File.directory?(path) real_path = File.realpath(path) - real_path if (File.readable?(real_path) && !File.directory?(real_path)) - rescue Errno::ENOENT - nil + + # Exclude stub files which include main config (e.g. Debian OS family) + File.foreach(real_path) do |line| + if line.match(/^configfile\s/) + real_path = nil + break + end + end end + + real_path end.compact.uniq fail(%{No grub configuration found at '#{paths.join("', '")}'}) if valid_paths.empty?