On 02/04/12 11:07, bruce bushby wrote: > Hi > > I've been writing a little module to handle some grub settings on RHEL > 6 and appear the have run into a silly little problem that I just > can't fix. > > I've trying to append the string "crashkernel=128M@16M" to the kernel > line in my grub.conf. The following module works 100% if I leave out > the "@" symbol. Any ideas how I can escape the "@" ?? > > I know I can use "crashkernel=auto" .... but I would like to know how > to insert any string I choose....even an "@".
The code snippet below also has a typo as it's missing the "=", so I think the combination of these two missing characters meant it worked for you. Anyway, I think that's a red herring for the real problem. > define insert ( $value ) { > $key = $name > $context = "/files/boot/grub/grub.conf" > augeas { "grub_conf/$key": > context => "$context", > changes => "insert '$value' after \'$key'", This bit of code where $value is "crashkernel=128M@16M" isn't doing the right thing. Augeas represents this as a label "crashkernel" with a value "128M@16M". The "insert" command takes just the label name, not the whole string. This is how it should look in augtool: augtool> print /files/boot/grub/menu.lst/title[1]/kernel /files/boot/grub/menu.lst/title[1]/kernel = "/vmlinuz-3.2.10-1.fc16.x86_64" [snip] /files/boot/grub/menu.lst/title[1]/kernel/KEYTABLE = "uk" /files/boot/grub/menu.lst/title[1]/kernel/quiet /files/boot/grub/menu.lst/title[1]/kernel/crashkernel = "128M@16M" When you use "insert", if it were possible, it would create: /files/boot/grub/menu.lst/title[1]/kernel/crashkernel=128M@16M = (none) So instead you need to use the set command to set both the label and value. Heading back to init.pp and using your existing define: grub::set { "/files/boot/grub/grub.conf/title[1]/kernel/crashkernel": value => "128M@16M" } I've also changed "title" to "title[1]" in case you have multiple kernels in grub.conf. A better idea is to use the "setm" (set multiple) command to set it on every kernel line, but you'll need Augeas 0.7.2, ruby-augeas 0.4.0 and Puppet 2.7.0. There's a good description here of how to use it, which you can wrap into a define again: http://planet.ergo-project.org/blog/jmeeuwen/2011/02/13/using-noop-io-scheduler-kvm-virtualization-through-puppet-and-augeas Hope that helps. -- Dominic Cleal Red Hat Consulting m: +44 (0)7817 878113 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.