[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-20 Thread David Lutterkort
On Wed, 2009-05-20 at 09:45 -0400, Rob McBroom wrote: > On 2009-May-19, at 4:09 PM, David Lutterkort wrote: > > > Think of the subtree under /2 etc. as a record - in almost all cases, > > these records have some notion of primary key; > > Which is why I wonder why /etc/inittab doesn't just use t

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-20 Thread Avi Miller
Hi Rob, Rob McBroom wrote: > err: //was/Augeas[shutdown]: Failed to retrieve current state of > resource: Error sending command 'ins 0 after *[id=' with params ["si", > "]"]/Command 'ins 0 after *[id=' is not supported I think you're hitting this bug that I reported: http://projects.reduc

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-20 Thread Rob McBroom
On 2009-May-19, at 4:09 PM, David Lutterkort wrote: > Think of the subtree under /2 etc. as a record - in almost all cases, > these records have some notion of primary key; Which is why I wonder why /etc/inittab doesn't just use the 'id' field instead of assigning a number, or why /etc/hosts d

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-19 Thread David Lutterkort
On Fri, 2009-05-15 at 14:41 -0400, Rob McBroom wrote: > However, what seems like a majority of files are broken up into an > "array" of values. Take the `/etc/exports` [example from the wiki][1]. > Existing items are assigned numbers 1-4 by Augeas when the file is > loaded. I should have lo

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-19 Thread David Lutterkort
On Fri, 2009-05-15 at 14:41 -0400, Rob McBroom wrote: > However, what seems like a majority of files are broken up into an > "array" of values. Take the `/etc/exports` [example from the wiki][1]. > Existing items are assigned numbers 1-4 by Augeas when the file is > loaded. > If you add a

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-19 Thread Trevor Vaughan
Brent, Thanks for the feedback. It felt like a bit of a hack when I wrote it but it very much follows the Puppet mentality of idempotency. I'm just starting to fiddle with Augeas since 90% of my problems fall into the precise declaration arena. Trevor On Mon, May 18, 2009 at 17:16, Brent Chap

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-19 Thread Bryan Kearney
Brent Chapman wrote: > On Mon, May 18, 2009 at 10:53 AM, Trevor Vaughan wrote: > >> While this is kind of kludg-y, might you try building the multipart >> file with Puppet itself: >> >> http://reductivelabs.com/trac/puppet/wiki/Recipes/BuildingMultipartFiles >> >> It's useful for building files w

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-18 Thread Brent Chapman
On Mon, May 18, 2009 at 10:53 AM, Trevor Vaughan wrote: > > While this is kind of kludg-y, might you try building the multipart > file with Puppet itself: > > http://reductivelabs.com/trac/puppet/wiki/Recipes/BuildingMultipartFiles > > It's useful for building files where you have chunked sections

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-18 Thread Brent Chapman
On Mon, May 18, 2009 at 9:01 AM, Rob McBroom wrote: > > On 2009-May-16, at 12:42 PM, Brent Chapman wrote: > > > If your goal is to append something to an Augeas list, then I think > > it's much better to use the [last()+1] notation. > > There are a couple of problems with that. Using last() is a b

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-18 Thread Trevor Vaughan
While this is kind of kludg-y, might you try building the multipart file with Puppet itself: http://reductivelabs.com/trac/puppet/wiki/Recipes/BuildingMultipartFiles It's useful for building files where you have chunked sections and, of course, you can use templates etc... where necessary. I ha

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-18 Thread Rob McBroom
On 2009-May-16, at 12:42 PM, Brent Chapman wrote: > If your goal is to append something to an Augeas list, then I think > it's much better to use the [last()+1] notation. There are a couple of problems with that. Using last() is a better method as far as general Augeas technique goes, but it

[Puppet Users] Re: dealing with numbered items in Augeas

2009-05-16 Thread Brent Chapman
I think that the heart of the problem is the convention of using "1" as an Augeas key to mean "add this to the end of the list". As Rob points out, you don't know how many items are already on the list. If there are less than 10,000 entries already, you wind up with funky numbering (1, 2, 3,