Hi guys, I was enlightened by the ''puppet+augeas modprobe.conf'' post (thanks!) and was going to put inittab under puppet/augeas management. My goal is to add this one line for spawning a console on the serial port if it doesn''t exist: co:12345:respawn:/sbin/agetty ttyS0 19200 vt100 However the task proved to be more tricky than I first imaged. There were two thing I was stuck on. Firstly inittab tree in augeas starts with number instead of arrays, and I had to work around to append with ins and last(). Secondly the match in onlyif didn''t seem to like spaces, so I was unsure how I can match the sequence exactly. I came up with the following: augeas { "inittab": context => "/files/etc/inittab", changes => [ "set 100/id ''co''", "set 100/runlevels 12345", "set 100/action respawn", "set 100/process \"/sbin/agetty ttyS0 19200 vt100\"", ], onlyif => "match */id[.=''co''] size == 0''", #onlyif => "match */process[.=''/sbin/agetty ttyS0 19200 vt100''] size == 0", } So for my first problem, I used an arbitary large number (100) so it''s outside the existing line ranges - not robust and could inadvertently overwrite something else. But for the matching, the first onlyif works but the commented out one would error with err: //Augeas[inittab]: Failed to retrieve current state of resource: Error sending command ''match'' with params ["vt100'']", "size", "==", "0"]/unknown error - Matching path expression ''/files/etc/inittab/*/ process[.=''/sbin/agetty'' failed I would really want to match on the serial console port (ttyS0) in case it''s named under a different id on an existing host. Did a search and found a previous issue at http://projects.reductivelabs.com/issues/1835 that looked similar, but the set I''ve used which contains spaces worked beautifully so this should be something else. Any ideas how I can achieve the append? Thanks very much. Hui --~--~---------~--~----~------------~-------~--~----~ 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 Fri, 2009-06-12 at 04:46 -0700, Hui wrote:> Hi guys, > > I was enlightened by the ''puppet+augeas modprobe.conf'' post (thanks!) > and was going to put inittab under puppet/augeas management. > > My goal is to add this one line for spawning a console on the serial > port if it doesn''t exist: > co:12345:respawn:/sbin/agetty ttyS0 19200 vt100 > > However the task proved to be more tricky than I first imaged. There > were two thing I was stuck on. Firstly inittab tree in augeas starts > with number instead of arrays, and I had to work around to append with > ins and last().Assuming you''re happy with appending that line to the end of the file, you shouldn''t need to do anything fancy .. just a bunch of set''s should be fine.> Secondly the match in onlyif didn''t seem to like > spaces, so I was unsure how I can match the sequence exactly.That is a bug that''s been addressed in the current master branch (ticket #2141)> I came up with the following: > augeas { "inittab": > context => "/files/etc/inittab", > changes => [ "set 100/id ''co''", > "set 100/runlevels 12345", > "set 100/action respawn", > "set 100/process \"/sbin/agetty ttyS0 19200 vt100\"", > ], > onlyif => "match */id[.=''co''] size == 0''", > #onlyif => "match */process[.=''/sbin/agetty ttyS0 19200 vt100''] > size == 0", > } > > So for my first problem, I used an arbitary large number (100) so it''s > outside the existing line ranges - not robust and could inadvertently > overwrite something else.A much better way to make sure numbered nodes are truly unique is to use labels that start with a ''0'' - you''re guaranteed that they will never appear in a tree that was just read from file; so you''d say "set 01/id ''co''" etc.> But for the matching, the first onlyif > works but the commented out one would error withThat can actually be also written as "match *[id=''co''] size == 0"> err: //Augeas[inittab]: Failed to retrieve current state of resource: > Error sending command ''match'' with params ["vt100'']", "size", "==", > "0"]/unknown error - Matching path expression ''/files/etc/inittab/*/ > process[.=''/sbin/agetty'' failedThat''s another manifestation of bug #2141.> I would really want to match on the serial console port (ttyS0) in > case it''s named under a different id on an existing host.This would really require that Augeas path expressions grow a way to match regexps or at least substrings, so that you could say onlyif => "match *[process =~ @^/sbin/agetty ttyS0@] size == 0" or some such. David --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks very much David, that explained it. I''ve changed the manifest to the following and it is now working fine. augeas { "inittab": context => "/files/etc/inittab", changes => [ "set 01/id ''co''", "set 01/runlevels 2345", "set 01/action respawn", "set 01/process \"/sbin/agetty ttyS0 19200 vt100\"", ], onlyif => "match *[id=''co''] size == 0", } Also that bug explained why my effort to manage limits.conf didn''t succeed: augeas { "limits.conf": context => "/files/etc/security/limits.conf", changes => [ "set domain[type=\"soft\"][item=\"nofile\"] ''1024''", "set domain[type=\"hard\"][item=\"nofile\"] ''65535''", ], } I''ll manage that with the file resource for now. Looking forward to the new version (currently on 0.24.8-1.el5.1) :) On Jun 12, 10:43 pm, David Lutterkort <lut...@redhat.com> wrote:> On Fri, 2009-06-12 at 04:46 -0700, Hui wrote: > > Hi guys, > > > I was enlightened by the ''puppet+augeas modprobe.conf'' post (thanks!) > > and was going to put inittab under puppet/augeas management. > > > My goal is to add this one line for spawning a console on the serial > > port if it doesn''t exist: > > co:12345:respawn:/sbin/agetty ttyS0 19200 vt100 > > > However the task proved to be more tricky than I first imaged. There > > were two thing I was stuck on. Firstly inittab tree in augeas starts > > with number instead of arrays, and I had to work around to append with > > ins and last(). > > Assuming you''re happy with appending that line to the end of the file, > you shouldn''t need to do anything fancy .. just a bunch of set''s should > be fine. > > > Secondly the match in onlyif didn''t seem to like > > spaces, so I was unsure how I can match the sequence exactly. > > That is a bug that''s been addressed in the current master branch (ticket > #2141) > > > > > I came up with the following: > > augeas { "inittab": > > context => "/files/etc/inittab", > > changes => [ "set 100/id ''co''", > > "set 100/runlevels 12345", > > "set 100/action respawn", > > "set 100/process \"/sbin/agetty ttyS0 19200 vt100\"", > > ], > > onlyif => "match */id[.=''co''] size == 0''", > > #onlyif => "match */process[.=''/sbin/agetty ttyS0 19200 vt100''] > > size == 0", > > } > > > So for my first problem, I used an arbitary large number (100) so it''s > > outside the existing line ranges - not robust and could inadvertently > > overwrite something else. > > A much better way to make sure numbered nodes are truly unique is to use > labels that start with a ''0'' - you''re guaranteed that they will never > appear in a tree that was just read from file; so you''d say "set 01/id > ''co''" etc. > > > But for the matching, the first onlyif > > works but the commented out one would error with > > That can actually be also written as "match *[id=''co''] size == 0" > > > err: //Augeas[inittab]: Failed to retrieve current state of resource: > > Error sending command ''match'' with params ["vt100'']", "size", "==", > > "0"]/unknown error - Matching path expression ''/files/etc/inittab/*/ > > process[.=''/sbin/agetty'' failed > > That''s another manifestation of bug #2141. > > > I would really want to match on the serial console port (ttyS0) in > > case it''s named under a different id on an existing host. > > This would really require that Augeas path expressions grow a way to > match regexps or at least substrings, so that you could say > > onlyif => "match *[process =~ @^/sbin/agetty ttyS0@] size == 0" > > or some such. > > David--~--~---------~--~----~------------~-------~--~----~ 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, 2009-06-15 at 08:07 -0700, iuhh wrote:> Thanks very much David, that explained it. > > I''ve changed the manifest to the following and it is now working fine. > augeas { "inittab": > context => "/files/etc/inittab", > changes => [ "set 01/id ''co''", > "set 01/runlevels 2345", > "set 01/action respawn", > "set 01/process \"/sbin/agetty ttyS0 19200 vt100\"", > ], > onlyif => "match *[id=''co''] size == 0", > }Just as a headsup: the next version of Augeas (the one after 0.5.1) will have a slightly different tree structure for inittab; we''ll use the id field from inittab as the name of the subtree for that line; with that, your example would become augeas { "inittab": context => "/files/etc/inittab", changes => [ "set co/runlevels 2345", "set co/action respawn", "set co/process \"/sbin/agetty ttyS0 19200 vt100\"", ], onlyif => "match co size == 0", } I generally try not to break the structure of the tree, but in this case I think it''s leads to a clear improvement. David --~--~---------~--~----~------------~-------~--~----~ 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 2009-Jun-15, at 6:49 PM, David Lutterkort wrote:> Just as a headsup: the next version of Augeas (the one after 0.5.1) > will > have a slightly different tree structure for inittab; we''ll use the id > field from inittab as the name of the subtree for that line;I think that will make a lot of people''s lives easier in the long run. Thanks! -- Rob McBroom <http://www.skurfer.com/> The magnitude of a problem does not affect its ownership. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---