voxpupuli / puppet-augeasproviders_grub

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

grub_config values with spaces cause augeas errors #44

Closed tparkercbn closed 5 years ago

tparkercbn commented 5 years ago

grub_config values with spaces cause augeus errors:

    grub_config {'GRUB_TERMINAL':
        value   => join($boot::grub_terminals, ' '),
        notify  => Exec['update-grub-config'],
    }

    grub_config {'GRUB_SERIAL_COMMAND':
        value   => "serial --unit=0 --speed=${boot::serialconsole}",
        notify  => Exec['update-grub-config'],
    }

Notice: /Stage[main]/Boot::Grub2/Grub_config[GRUB_TERMINAL]/value: value changed '"console serial"' to 'console serial' Error: /Stage[main]/Boot::Grub2/Grub_config[GRUB_TERMINAL]: Could not evaluate: Failed to save Augeas tree to file. See debug logs for details.

Notice: /Stage[main]/Boot::Grub2/Grub_config[GRUB_SERIAL_COMMAND]/value: value changed '"serial --unit=0 --speed=115200"' to 'serial --unit=0 --speed=115200' Error: /Stage[main]/Boot::Grub2/Grub_config[GRUB_SERIAL_COMMAND]: Could not evaluate: Failed to save Augeas tree to file. See debug logs for details.

trevor-vaughan commented 5 years ago

@tparkercbn Can you please test this directly with augtool to help pinpoint whether it is a lens issue or a provider issue?

trevor-vaughan commented 5 years ago

Interesting (and unexpected). If you add single quotes inside your double quotes around the value parameters in your resource declarations does that work or is it invalid?

tparkercbn commented 5 years ago

Sorry. I deleted the prevous comment as I realized that it was still in an error state so the quotes change were not actually helping. I added a set of \" \" to my value and that works.

My working config is this:

    grub_config {'GRUB_TERMINAL':
        value   => "\"${join($boot::grub_terminals, ' ')}\"",
        notify  => Exec['update-grub-config'],
    }

    grub_config {'GRUB_SERIAL_COMMAND':
        value   => "\"serial --unit=0 --speed=${boot::serialconsole}\"",
        notify  => Exec['update-grub-config'],
    }
tparkercbn commented 5 years ago

augtool> get etc/default/grub/GRUB_TERMINAL etc/default/grub/GRUB_TERMINAL = "console serial" augtool> set etc/default/grub/GRUB_TERMINAL '"console serial foo"' augtool> save Saved 1 file(s) augtool> set etc/default/grub/GRUB_TERMINAL '"console serial"' augtool> save Saved 1 file(s) augtool>

trevor-vaughan commented 5 years ago

OK, should be easy enough to fix.

trevor-vaughan commented 5 years ago

Everything looks OK in your /etc/default/grub file after adding the quotes, right?

tparkercbn commented 5 years ago

yes. The values are double quoted as expected:

Notice: /Stage[main]/Boot::Grub2/Grub_config[GRUB_TERMINAL]/value: value changed '"console serial foo"' to '"console serial"'

cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_CMDLINE_LINUX="root=/dev/vdb console=tty1 console=ttyS0,115200n8 rd.net.timeout.dhcp=2 biosdevname=0 net.ifnames=0" GRUB_DISABLE_RECOVERY="true" GRUB_TERMINAL="console serial" GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200" GRUB_DISABLE_OS_PROBER="true"

trevor-vaughan commented 5 years ago

Rolling this and #45 into the same patch. Should have a PR later tonight.

tparkercbn commented 5 years ago

if you have a branch I can clone I can give it a test.

trevor-vaughan commented 5 years ago

@tparkercbn https://github.com/trevor-vaughan/augeasproviders_grub/tree/boolean_fix

tparkercbn commented 5 years ago

I'm getting very odd behaviour now.

1. The boolean value is being "corrected" on every run but makes no changes to /etc/default/grub

Notice: /Stage[main]/Boot::Grub2/Grub_config[GRUB_DISABLE_OS_PROBER]/value: value changed '"true"' to 'true' (corrective)

  1. If the lines with spaces do not exist in the file at all: Notice: /Stage[main]/Boot::Grub2/Grub_config[GRUB_TERMINAL]/ensure: created (corrective) Debug: Puppet::Type::Grub_config::ProviderGrub2: Save failure details: /augeas/files/etc/default/grub/error/path = /files/etc/default/grub/files/etc/default/grub/GRUB_TERMINAL /augeas/files/etc/default/grub/error/lens = /opt/puppetlabs/puppet/share/augeas/lenses/dist/shellvars.aug:70.18-.39: /augeas/files/etc/default/grub/error/message = None of the alternatives in the union match Error: /Stage[main]/Boot::Grub2/Grub_config[GRUB_TERMINAL]: Could not evaluate: Failed to save Augeas tree to file. See debug logs for details.

  2. If the lines exist but are wrong: Nothing happens at all, it's as if that setting is not in the catalog.

tparkercbn commented 5 years ago
  1. If the boolean value does not exist, it gets added. Then goes back into the loop as per 1 above.
trevor-vaughan commented 5 years ago

I think I've isolated it in the acceptance tests. Will get those working and prod again when I can.

tparkercbn commented 5 years ago

Sounds good! I have a working config with the \" workaround for now. Let me know if I can help with more testing. I have an r10k environment setup to pull from your branch.

trevor-vaughan commented 5 years ago

@tparkercbn Try again whenever you get a chance

tparkercbn commented 5 years ago

Good morning.

I have been completely unable to get this to break no matter what I throw at it.

Thank you very much for the fixes, it's working perfectly.