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_config values with spaces cause augeas errors #44

Closed
tparkercbn opened this issue Jul 29, 2019 · 16 comments · Fixed by #46
Closed

grub_config values with spaces cause augeas errors #44

tparkercbn opened this issue Jul 29, 2019 · 16 comments · Fixed by #46

Comments

@tparkercbn
Copy link
Contributor

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.

@tparkercbn tparkercbn changed the title grub_config grub_config values with sapces cause augeas errors Jul 29, 2019
@trevor-vaughan
Copy link
Contributor

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

@trevor-vaughan
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor

OK, should be easy enough to fix.

@trevor-vaughan
Copy link
Contributor

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

@tparkercbn
Copy link
Contributor Author

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
Copy link
Contributor

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

@tparkercbn
Copy link
Contributor Author

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

@tparkercbn tparkercbn changed the title grub_config values with sapces cause augeas errors grub_config values with spaces cause augeas errors Jul 29, 2019
trevor-vaughan added a commit to trevor-vaughan/augeasproviders_grub that referenced this issue Jul 29, 2019
* Ensure that Boolean values are converted to Strings
* Ensure the String values have quotes around them if not already
  present

Fixes voxpupuli#44, voxpupuli#45
@tparkercbn
Copy link
Contributor Author

I'm getting very odd behaviour now.

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
Copy link
Contributor Author

  1. If the boolean value does not exist, it gets added. Then goes back into the loop as per 1 above.

@trevor-vaughan
Copy link
Contributor

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

@trevor-vaughan trevor-vaughan changed the title grub_config values with spaces cause augeas errors WIP: grub_config values with spaces cause augeas errors Jul 30, 2019
@tparkercbn
Copy link
Contributor Author

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
Copy link
Contributor

@tparkercbn Try again whenever you get a chance

@trevor-vaughan trevor-vaughan changed the title WIP: grub_config values with spaces cause augeas errors grub_config values with spaces cause augeas errors Jul 30, 2019
@tparkercbn
Copy link
Contributor Author

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.

trevor-vaughan added a commit to trevor-vaughan/augeasproviders_grub that referenced this issue Jul 31, 2019
* Ensure that Boolean values are converted to Strings
* Ensure the String values have quotes around them if not already
  present

Fixes voxpupuli#44, voxpupuli#45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants