voxpupuli / puppet-augeasproviders_grub

Augeas-based grub type and providers
Apache License 2.0
9 stars 33 forks source link

Grub2 does not add the /files/etc/default/grub/GRUB_CMDLINE_LINUX_DEFAULT path if it is missing #11

Closed trevor-vaughan closed 8 years ago

trevor-vaughan commented 9 years ago

Attempted to apply the following with Puppet:

kernel_parameter { 'fips':
  value    => '1',
  bootmode => 'normal'
}

Received the following error:

Info: Applying configuration version '1445871089'
Notice: /Stage[main]/Main/Kernel_parameter[fips]/ensure: created
Debug: Puppet::Type::Kernel_parameter::ProviderGrub2: Save failure details:
/augeas/files/etc/default/grub/error/path = /files/etc/default/grub/GRUB_CMDLINE_LINUX_DEFAULT
/augeas/files/etc/default/grub/error/lens = /usr/share/augeas/lenses/dist/shellvars_list.aug:38.13-.78:
/augeas/files/etc/default/grub/error/message = Failed to match 
    { /quote/ = /'/ }({ /value/ = /[^\001-\004\t\n ']+/ }{ /value/ = /[^\001-\004\t\n ']+/ }*)? | { /quote/ = /"/ }({ /value/ = /([^\001-\004\t\n "\\]|\\\\[^\001-\004\n])+/ }{ /value/ = /([^\001-\004\t\n "\\]|\\
\\[^\001-\004\n])+/ }*)? | { /quote/ = // }{ /value/ = /(([^\001-\004\t\n "'\\]|\\\\[^\001-\004\n])+)+/ }?
  with tree
    { "value" = "fips=1" }
Error: /Stage[main]/Main/Kernel_parameter[fips]: Could not evaluate: Failed to save Augeas tree to file. See debug logs for details.

This appears to be because GRUB_CMDLINE_LINUX_DEFAULT is not present in /etc/default/grub by default and should be created by Augeas if it is not present in the file.

Ideally, it would default to whatever GRUB_CMDLINE_LINUX has in it at the time of creation.

raphink commented 9 years ago

Good catch it seems. Could you try to provide tests for this?

trevor-vaughan commented 9 years ago

Here you go: https://github.com/trevor-vaughan/grub_test

bundle rake acceptance

raphink commented 9 years ago

OK. I would have preferred a PR adding a test to this module instead of external code.

trevor-vaughan commented 9 years ago

Fair enough.

Are you OK with the approach that I used in that link? I can port it in, just not for a few days.

raphink commented 9 years ago

Take your time. I'm afk for another 10 days, can't really thoroughly review from my phone.