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 tt...@] 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---