Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grub_menuentry resource fail if directory /boot/grub doe not exist #53

Closed
aursu opened this issue Apr 23, 2020 · 5 comments · Fixed by #56
Closed

grub_menuentry resource fail if directory /boot/grub doe not exist #53

aursu opened this issue Apr 23, 2020 · 5 comments · Fixed by #56
Assignees
Labels
bug Something isn't working

Comments

@aursu
Copy link

aursu commented Apr 23, 2020

Hello, there is a bug inside grub2 provider for custom type Grub_menuentry which cause next behaviour:

Notice: /Stage[main]/Kernel/Grub_menuentry[Puppet-Managed Kernel Entry]/default_entry: default_entry changed false to true (corrective)
Debug: Executing: '/usr/sbin/grub2-mkconfig'
Error: /Grub_menuentry[Puppet-Managed Kernel Entry]: Could not evaluate: No such file or directory @ rb_sysopen - /boot/grub/grub.cfg
Notice: /Stage[main]/Kernel/File_line[grubenv saved_entry]: Dependency Grub_menuentry[Puppet-Managed Kernel Entry] has failures: true
Warning: /Stage[main]/Kernel/File_line[grubenv saved_entry]: Skipping because of failed dependencies

Bug is inside this block of method grub2_mkconfig

    cfg_paths.uniq.each do |cfg_path|
      File.open(cfg_path, 'w') do |fh|
        fh.puts(mkconfig_output)
        fh.flush
      end
    end

if folder /boot/grub is not existing it will fail with

Errno::ENOENT: No such file or directory @ rb_sysopen - /boot/grub/grub.cfg

Please review and fix it

@trevor-vaughan
Copy link
Contributor

@aursu This is an accurate error. Nothing can be done if the grub configuration is not present.

Would you prefer a more clean early bail out if no target files can be found?

@aursu
Copy link
Author

aursu commented Apr 24, 2020

@aursu This is an accurate error. Nothing can be done if the grub configuration is not present.

Would you prefer a more clean early bail out if no target files can be found?

Hello, @trevor-vaughan

You are right. this issue should be categorised as feature request rather than bug

Let me explain. There is parameter cfg_paths for method grub2_mkconfig. It is defined as list of configuration files paths which all (without exceptions) must be writable. Otherwise block https://github.com/hercules-team/augeasproviders_grub/blob/316d74750a9c2f7674fdb9d5b8c85c6a7b2aaea3/lib/puppet/provider/grub_menuentry/grub2.rb#L788 will fail with exception I've mentioned above

The trouble is that path /boot/grub/grub.cfg is default path for vanilla Grub2 version and Debian based distros (I've found at least in Ubuntu documentation).

But RedHat and consequently CentOS default is /boot/grub2/grub.cfg therefore missed /boot/grub directory is not an issue on these distros. But : grub_menuentry requires (implicitly) this path to be existing.

Therefore I propose to add some conditional checks which will allow to not fail but just skip /boot/grub/grub.cfg on RedHat based distros

As workaround to this issue I've added resource file { '/boot/grub': ensure => directory, before => Grub_menuentry['Puppet-Managed Kernel Entry'], } into catalog but in my opinion it should be resolved on provider level

Thank you

@trevor-vaughan
Copy link
Contributor

Interesting. It was tested primarily on CentOS systems!

I'll double check that the acceptance tests are picking it up and go from there.

@trevor-vaughan
Copy link
Contributor

@aursu Determined that this is a legit bug. The logic isn't quite right. Prodding and will push a patch when things are in order.

@trevor-vaughan trevor-vaughan added the bug Something isn't working label Apr 24, 2020
trevor-vaughan added a commit to trevor-vaughan/augeasproviders_grub that referenced this issue Apr 28, 2020
* Fix legacy GRUB issue due to missing updates to the provider (test
  node had been commented out)
* Fix processing of the menuentry generation in GRUB2

Fixes voxpupuli#53
@trevor-vaughan trevor-vaughan self-assigned this Apr 28, 2020
@trevor-vaughan
Copy link
Contributor

@aursu Can you try out the associated patch and let me know if it resolves your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants