Just to be clear: I am offering to write what I describe below if it seems acceptable to others (and if I get the time). I love the idea of Augeas, and I love that Puppet has built-in support for it. However, I''m finding that I''m routinely unable to do things with the Puppet Augeas type that I could trivially do with augtool and /bin/sh. So, here''s some examples and how I think they could be fixed. Example 1 --------- Let''s pretend that there was no alias type in Puppet (just because it''s a file everyone''s familiar with). Let''s say that I wanted to set the postmaster alias to foo@bar.com using Augeas. The problem is, I have no idea what the Augeas path for postmaster is. The shell solution is something like: path=$(augtool match /files/etc/aliases/\*/name postmaster | sed ''s;/[^/]*$;;'') augtool set $path/value foo@bar.com I can''t see any way to do anything like this in the Augeas type we have now, so I propose the following extensions, which would conflict with the "changes" argument. This would limit things to one change per Augeas type entry as far as I can tell, but oh well. command => set path => STRING value => STRING command => insert/ins where => before/after path => STRING value => STRING command => mv path => STRING destination => STRING command => rm/remove/delete path => STRING command => clear path => STRING Nothing terribly exciting there; the new bit is that instead of "path" you can use one of these: match_path => STRING match_type => int/integer/size match_args => [ COMPARATOR, INT ] match_path => STRING match_type => regex/not_regex match_args => [ STRING ] match_path => STRING match_type => in/not_in match_args => [ STRING, STRING, ... ] The "size" and "in" types are basically identical to the current onlyif stuff. regex looks for a path that matches the given regex. not_in and not_regex match if the string isn''t found or doesn''t match the regex, respectively. In addition, they all take: match_post_regex => [ STRING, STRING ] which takes the matched path and essentially does path.sub!( regex[0], regex[1] ). The point being to do what the sed in the shell example above does. The result of all the match_path stuff is treated as the path value for the set, insert, or mv. Example 2 --------- Again, working with the aliases file. I want to add an alias from "foo" to "bar@baz.com", but obviously I only want to add it once. onlyif won''t work, but I really don''t like the syntax of onlyif anyways: it''s not Puppet-like, and it doesn''t actually match how augtool works either. So, I propose this, based on the above: onlyif_match_path => STRING onlyif_match_type => int/integer/size onlyif_match_args => [ COMPARATOR, INT ] onlyif_match_path => STRING onlyif_match_type => regex/not_regex onlyif_match_args => [ STRING ] onlyif_match_path => STRING onlyif_match_type => in/not_in onlyif_match_args => [ STRING, STRING, ... ] This does everything the current onlyif does, and quite a bit more besides. There is no equivalent to match_post_regex, because the onlyif_match_* isn''t actually used to do anything, the way match_* is. -Robin -- They say: "The first AIs will be built by the military as weapons." And I''m thinking: "Does it even occur to you to try for something other than the default outcome?" -- http://shorl.com/tydruhedufogre http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Robin Lee Powell wrote:> > Just to be clear: I am offering to write what I describe below if it > seems acceptable to others (and if I get the time). > > I love the idea of Augeas, and I love that Puppet has built-in > support for it. However, I''m finding that I''m routinely unable to > do things with the Puppet Augeas type that I could trivially do with > augtool and /bin/sh. So, here''s some examples and how I think they > could be fixed. > > Example 1 > --------- > > Let''s pretend that there was no alias type in Puppet (just because > it''s a file everyone''s familiar with). Let''s say that I wanted to > set the postmaster alias to foo@bar.com using Augeas. The problem > is, I have no idea what the Augeas path for postmaster is. The > shell solution is something like: > > path=$(augtool match /files/etc/aliases/\*/name postmaster | sed ''s;/[^/]*$;;'') > > augtool set $path/value foo@bar.com > > I can''t see any way to do anything like this in the Augeas type we > have now, so I propose the following extensions, which would > conflict with the "changes" argument. This would limit things to > one change per Augeas type entry as far as I can tell, but oh well. > > command => set > path => STRING > value => STRING > > command => insert/ins > where => before/after > path => STRING > value => STRING > > command => mv > path => STRING > destination => STRING > > command => rm/remove/delete > path => STRING > > command => clear > path => STRING > > Nothing terribly exciting there; the new bit is that instead of > "path" you can use one of these: > > match_path => STRING > match_type => int/integer/size > match_args => [ COMPARATOR, INT ] > > match_path => STRING > match_type => regex/not_regex > match_args => [ STRING ] > > match_path => STRING > match_type => in/not_in > match_args => [ STRING, STRING, ... ] > > The "size" and "in" types are basically identical to the current > onlyif stuff. regex looks for a path that matches the given regex. > not_in and not_regex match if the string isn''t found or doesn''t > match the regex, respectively. > > In addition, they all take: > > match_post_regex => [ STRING, STRING ] > > which takes the matched path and essentially does path.sub!( > regex[0], regex[1] ). The point being to do what the sed in the > shell example above does. > > The result of all the match_path stuff is treated as the path value > for the set, insert, or mv.I see the value in this model, but it seems that if this is a common use of augeas, we should look to push this into augeas.. and then expose it through the plugin instead of wrapping logic around it. David L... is this something which you would look to include in augeas?> > Example 2 > --------- > > Again, working with the aliases file. I want to add an alias from > "foo" to "bar@baz.com", but obviously I only want to add it once. > onlyif won''t work, but I really don''t like the syntax of onlyif > anyways: it''s not Puppet-like, and it doesn''t actually match how > augtool works either. So, I propose this, based on the above:Actually.. onlyif is modeled after exec.. so there is some precendence in puppet proper.> > onlyif_match_path => STRING > onlyif_match_type => int/integer/size > onlyif_match_args => [ COMPARATOR, INT ] > > onlyif_match_path => STRING > onlyif_match_type => regex/not_regex > onlyif_match_args => [ STRING ] > > onlyif_match_path => STRING > onlyif_match_type => in/not_in > onlyif_match_args => [ STRING, STRING, ... ] > > This does everything the current onlyif does, and quite a bit more > besides.The only thing added here is the regex.. is that correct? -- bk --~--~---------~--~----~------------~-------~--~----~ 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, Jan 19, 2009 at 09:12:25AM -0500, Bryan Kearney wrote:> > Example 2 > > --------- > > > > Again, working with the aliases file. I want to add an alias from > > "foo" to "bar@baz.com", but obviously I only want to add it once. > > onlyif won''t work, but I really don''t like the syntax of onlyif > > anyways: it''s not Puppet-like, and it doesn''t actually match how > > augtool works either. So, I propose this, based on the above: > > Actually.. onlyif is modeled after exec.. so there is some precendence > in puppet proper.It''s not the onlyif that bothers me, it''s the weird string-parsing thing.> > onlyif_match_path => STRING > > onlyif_match_type => int/integer/size > > onlyif_match_args => [ COMPARATOR, INT ] > > > > onlyif_match_path => STRING > > onlyif_match_type => regex/not_regex > > onlyif_match_args => [ STRING ] > > > > onlyif_match_path => STRING > > onlyif_match_type => in/not_in > > onlyif_match_args => [ STRING, STRING, ... ] > > > > This does everything the current onlyif does, and quite a bit more > > besides. > > The only thing added here is the regex.. is that correct?More importantly, not_regex and not_in -Robin -- They say: "The first AIs will be built by the military as weapons." And I''m thinking: "Does it even occur to you to try for something other than the default outcome?" -- http://shorl.com/tydruhedufogre http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ --~--~---------~--~----~------------~-------~--~----~ 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 Sun, 2009-01-18 at 18:37 -0800, Robin Lee Powell wrote:> Let''s pretend that there was no alias type in Puppet (just because > it''s a file everyone''s familiar with). Let''s say that I wanted to > set the postmaster alias to foo@bar.com using Augeas. The problem > is, I have no idea what the Augeas path for postmaster is. The > shell solution is something like: > > path=$(augtool match /files/etc/aliases/\*/name postmaster | sed ''s;/[^/]*$;;'') > > augtool set $path/value foo@bar.comThis is what I am trying to address with better path expressions in Augeas itself. That lets you write set "/files/etc/aliases/*[name = ''postmaster'']/value" foo@bar.com to do exactly the same thing. Path expressions are modeled on XPath, and the patches I have (and still need to clean up some, but I''ve never been closer) implement a subset of XPath that makes it possible to write down pretty powerful queries as one expression> I can''t see any way to do anything like this in the Augeas type we > have now, so I propose the following extensions, which would > conflict with the "changes" argument. This would limit things to > one change per Augeas type entry as far as I can tell, but oh well. > > command => set > path => STRING > value => STRING > > command => insert/ins > where => before/after > path => STRING > value => STRING > > command => mv > path => STRING > destination => STRING > > command => rm/remove/delete > path => STRING > > command => clear > path => STRINGIsn''t that just splitting the mini-language that changes currently understands into attributes on the puppet level ?> Nothing terribly exciting there; the new bit is that instead of > "path" you can use one of these: > > match_path => STRING > match_type => int/integer/size > match_args => [ COMPARATOR, INT ] > > match_path => STRING > match_type => regex/not_regex > match_args => [ STRING ] > > match_path => STRING > match_type => in/not_in > match_args => [ STRING, STRING, ... ] > > The "size" and "in" types are basically identical to the current > onlyif stuff. regex looks for a path that matches the given regex. > not_in and not_regex match if the string isn''t found or doesn''t > match the regex, respectively.This mostly maps to ''predicates'' in the path expressions; I don''t have support for regex matching in there yet, but other than that what you describe above is covered. This sort of brains (slicing and dicing the Augeas tree) really belongs into Augeas - the Puppet type should mostly bridge the gap between Augeas'' command-oriented structure and Puppet''s state-oriented veiw of the world.> Example 2 > --------- > > Again, working with the aliases file. I want to add an alias from > "foo" to "bar@baz.com", but obviously I only want to add it once.Again, expanded path expressions will help you here, since you can then say onlyif => "match /files/etc/aliases/*[name = ''foo''] size == 0" 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, Jan 19, 2009 at 01:28:53PM -0800, David Lutterkort wrote:> > On Sun, 2009-01-18 at 18:37 -0800, Robin Lee Powell wrote: > > Let''s pretend that there was no alias type in Puppet (just > > because it''s a file everyone''s familiar with). Let''s say that I > > wanted to set the postmaster alias to foo@bar.com using Augeas. > > The problem is, I have no idea what the Augeas path for > > postmaster is. The shell solution is something like: > > > > path=$(augtool match /files/etc/aliases/\*/name postmaster | sed ''s;/[^/]*$;;'') > > > > augtool set $path/value foo@bar.com > > This is what I am trying to address with better path expressions in > Augeas itself. That lets you write > > set "/files/etc/aliases/*[name = ''postmaster'']/value" > foo@bar.com > > to do exactly the same thing.That''d be excellent. I''d want a regex option there too, though. Any idea when this will be out?> Path expressions are modeled on XPath, and the patches I have (and > still need to clean up some, but I''ve never been closer) implement > a subset of XPath that makes it possible to write down pretty > powerful queries as one expressionCoolness.> > I can''t see any way to do anything like this in the Augeas type > > we have now, so I propose the following extensions, which would > > conflict with the "changes" argument. This would limit things > > to one change per Augeas type entry as far as I can tell, but oh > > well. > > > > command => set > > path => STRING > > value => STRING > > > > command => insert/ins > > where => before/after > > path => STRING > > value => STRING > > > > command => mv > > path => STRING > > destination => STRING > > > > command => rm/remove/delete > > path => STRING > > > > command => clear > > path => STRING > > Isn''t that just splitting the mini-language that changes currently > understands into attributes on the puppet level ?I''m not sure I understand the question, but that was all from a Puppet perspective. Puppet does not give access to the results from match or get, you see, and what it does do works quite a bit differently than those. See http://reductivelabs.com/trac/puppet/wiki/TypeReference#augeas> > Nothing terribly exciting there; the new bit is that instead of > > "path" you can use one of these: > > > > match_path => STRING > > match_type => int/integer/size > > match_args => [ COMPARATOR, INT ] > > > > match_path => STRING > > match_type => regex/not_regex > > match_args => [ STRING ] > > > > match_path => STRING > > match_type => in/not_in > > match_args => [ STRING, STRING, ... ] > > > > The "size" and "in" types are basically identical to the current > > onlyif stuff. regex looks for a path that matches the given regex. > > not_in and not_regex match if the string isn''t found or doesn''t > > match the regex, respectively. > > This mostly maps to ''predicates'' in the path expressions; I don''t > have support for regex matching in there yet, but other than that > what you describe above is covered.But not actually available currently, correct?> This sort of brains (slicing and dicing the Augeas tree) really > belongs into Augeas - the Puppet type should mostly bridge the gap > between Augeas'' command-oriented structure and Puppet''s > state-oriented veiw of the world.Fair enough. I didn''t know you were trying to do this kind of stuff on your end, and like I said, I was prepared to write the Puppet stuff myself, because I can. I really can''t help you with the Augeas stuff, and I''m feeling impatient. :) I''ll try to hold off, though. -Robin -- They say: "The first AIs will be built by the military as weapons." And I''m thinking: "Does it even occur to you to try for something other than the default outcome?" -- http://shorl.com/tydruhedufogre http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ --~--~---------~--~----~------------~-------~--~----~ 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 Sun, 2009-01-25 at 15:21 -0800, Robin Lee Powell wrote:> On Mon, Jan 19, 2009 at 01:28:53PM -0800, David Lutterkort wrote: > > > > > > This is what I am trying to address with better path expressions in > > Augeas itself. That lets you write > > > > set "/files/etc/aliases/*[name = ''postmaster'']/value" > > foo@bar.com > > > > to do exactly the same thing. > > That''d be excellent. I''d want a regex option there too, though.Can you post some examples of how you''d want to use regexes to augeas-devel ?> Any idea when this will be out?In the next release - I posted patches to the list to implement that, just needs some volunteers to play with it some ;)> > This sort of brains (slicing and dicing the Augeas tree) really > > belongs into Augeas - the Puppet type should mostly bridge the gap > > between Augeas'' command-oriented structure and Puppet''s > > state-oriented veiw of the world. > > Fair enough. I didn''t know you were trying to do this kind of stuff > on your end, and like I said, I was prepared to write the Puppet > stuff myself, because I can. I really can''t help you with the > Augeas stuff, and I''m feeling impatient. :)But yes, you can .. by trying out the new XPath support and figuring out where it falls short of what you need ;) 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 -~----------~----~----~----~------~----~------~--~---
Robin Lee Powell wrote:> > Just to be clear: I am offering to write what I describe below if it > seems acceptable to others (and if I get the time). > > I love the idea of Augeas, and I love that Puppet has built-in > support for it. However, I''m finding that I''m routinely unable to > do things with the Puppet Augeas type that I could trivially do with > augtool and /bin/sh. So, here''s some examples and how I think they > could be fixed.Just resurrecting this thread. Please check out bug 1826 with a new (.4 or later) augeas and see if that meets your needs. -- bk --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---