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 "@".
Thanks
init.pp:
class grub {
include grub::grub
grub::set {
"timeout": value => 10;
}
grub::insert {
"/files/boot/grub/grub.conf/title/kernel/ro": value
=>
''crashkerne128M@16M'';
}
}
grub.pp:
class grub::grub {
define set ( $value ) {
$key = $name
$context = "/files/boot/grub/grub.conf"
augeas { "grub_conf/$key":
context => "$context",
onlyif => "get $key !=
''$value''",
changes => "set $key
''$value''",
incl => ''/boot/grub/grub.conf'',
lens => ''grub.lns'',
}
}
define insert ( $value ) {
$key = $name
$context = "/files/boot/grub/grub.conf"
augeas { "grub_conf/$key":
context => "$context",
changes => "insert ''$value''
after \''$key''",
incl => ''/boot/grub/grub.conf'',
lens => ''grub.lns'',
}
}
file { "grub_conf":
name => $operatingsystem ? {
default => "/boot/grub/grub.conf",
},
}
}
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
On Apr 2, 5:07 am, bruce bushby <bruce.bus...@gmail.com> 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 ''@'' character in your sample is not special to Puppet, so the first step is to figure out which tool in the chain is choking on it. I suppose that would probably be Augeas. I''m not proficient in Augeas, however, so I can''t be sure, and I certainly can''t tell you how Augeas escaping works. John -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Mon, Apr 2, 2012 at 16:10, jcbollinger <John.Bollinger@stjude.org> wrote:> > > On Apr 2, 5:07 am, bruce bushby <bruce.bus...@gmail.com> 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 ''@'' character in your sample is not special to Puppet, so the > first step is to figure out which tool in the chain is choking on it. > I suppose that would probably be Augeas. I''m not proficient in > Augeas, however, so I can''t be sure, and I certainly can''t tell you > how Augeas escaping works. > > > John > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >John, I thought the @ was used to define a virtual resource. Does that not give it special meaning to puppet? John -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Apr 2, 10:44 am, John Kennedy <skeb...@gmail.com> wrote:> I thought the @ was used to define a virtual resource. Does that not give > it special meaning to puppet?Not in the context (i.e. quoted) in which it appears in your manifest. John -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.