agentk
2009-Apr-06 06:10 UTC
[Puppet Users] puppet + augeas /etc/exports/dir[*] lookup possible?
I''m not sure if I''m kicking tyres again, but first off: I like the possibilities with puppet + augeas. Trying to make a working example with /etc/exports but not sure of how to proceed. I want to be able to define exports in the following form: my_exports_def { [''/home/server01'', ''/svr/logs'']: client => ''*.example.com'', options => ''rw,sync'', ''/other/export'': client => ''*.example.com'', options => ''rw,sync,no_root_squash'', } I am not sure if I should remove /files/etc/exports/dir first or just remove the dir of the export I''m adding and how do I refer to a dir[n] subtree by the export name to be able to remove or modify one? ie match /files/etc/exports/dir "/home/server01" Or should I just clear /files/etc/exports and set everything like in the PuppetAugeas example? Just not sure on the puppet/augeas way of doing this. Regards, Karl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bryan Kearney
2009-Apr-06 13:59 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
agentk wrote:> I''m not sure if I''m kicking tyres again, but first off: I like the > possibilities with puppet + augeas. > > Trying to make a working example with /etc/exports but not sure of how > to proceed. I want to be able to define exports in the following form: > > my_exports_def { > [''/home/server01'', ''/svr/logs'']: > client => ''*.example.com'', > options => ''rw,sync'', > ''/other/export'': > client => ''*.example.com'', > options => ''rw,sync,no_root_squash'', > } >Try something like this: augeas{"test": context=>"/files/etc/exports", changes => ["set /dir[.=''/home/server01''] ''/home/server01''", "set /dir[.=''/home/server01'']/client ''*.example.com''", "set /dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw''] rw"] } The commands work in augtool. The iteration may be an issue if you have many options. Perhaps you can set that up in a wrapper call and use conditionals? -- 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 -~----------~----~----~----~------~----~------~--~---
Karl Bowden
2009-Apr-07 01:46 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Mon, Apr 6, 2009 at 11:59 PM, Bryan Kearney <bkearney@redhat.com> wrote:> > agentk wrote: >> I''m not sure if I''m kicking tyres again, but first off: I like the >> possibilities with puppet + augeas. >> >> Trying to make a working example with /etc/exports but not sure of how >> to proceed. I want to be able to define exports in the following form: >> >> my_exports_def { >> [''/home/server01'', ''/svr/logs'']: >> client => ''*.example.com'', >> options => ''rw,sync'', >> ''/other/export'': >> client => ''*.example.com'', >> options => ''rw,sync,no_root_squash'', >> } >> > > Try something like this: > > augeas{"test": > context=>"/files/etc/exports", > changes => ["set /dir[.=''/home/server01''] ''/home/server01''", > "set /dir[.=''/home/server01'']/client ''*.example.com''", > "set > /dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw''] rw"] > > } > > The commands work in augtool. The iteration may be an issue if you have > many options. Perhaps you can set that up in a wrapper call and use > conditionals? > > -- bkCheers! Your example did not work at first, but I just needed to package the latest augeas for ubuntu. I think that is where half of my trouble was. Oh well. All good now thank you. - Karl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Karl Bowden
2009-Apr-07 05:41 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Tue, Apr 7, 2009 at 11:46 AM, Karl Bowden <karlbowden@gmail.com> wrote:> On Mon, Apr 6, 2009 at 11:59 PM, Bryan Kearney <bkearney@redhat.com> wrote: >> >> agentk wrote: >>> I''m not sure if I''m kicking tyres again, but first off: I like the >>> possibilities with puppet + augeas. >>> >>> Trying to make a working example with /etc/exports but not sure of how >>> to proceed. I want to be able to define exports in the following form: >>> >>> my_exports_def { >>> [''/home/server01'', ''/svr/logs'']: >>> client => ''*.example.com'', >>> options => ''rw,sync'', >>> ''/other/export'': >>> client => ''*.example.com'', >>> options => ''rw,sync,no_root_squash'', >>> } >>> >> >> Try something like this: >> >> augeas{"test": >> context=>"/files/etc/exports", >> changes => ["set /dir[.=''/home/server01''] ''/home/server01''", >> "set /dir[.=''/home/server01'']/client ''*.example.com''", >> "set >> /dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw''] rw"] >> >> } >> >> The commands work in augtool. The iteration may be an issue if you have >> many options. Perhaps you can set that up in a wrapper call and use >> conditionals? >> >> -- bk > > Cheers! Your example did not work at first, but I just needed to > package the latest augeas for ubuntu. I think that is where half of my > trouble was. Oh well. All good now thank you. > > - Karl >Ok, I''m almost there. But not quite. First here is the code I''m using: templates/augeas/exports.erb: set /dir[.=''<%= name %>''] ''<%= name %>'' set /dir[.=''<%= name %>'']/client[.=''<%= client %>''] ''<%= client %>'' remove /dir[.=''<%= name %>'']/client[.=''<%= client %>'']/option <% options.each do |option| %>set /dir[.=''<%= name %>'']/client[.=''<%client %>'']/option[.=''<%= option %>''] ''<%= option %>'' <% end %> manifests/templates.pp: define augeas_nfs_export($client=''*'', $options=[''ro'',''sync'']) { augeas { "$name": context => "/files/etc/exports", changes => template(''augeas/exports.erb''), } } class virt02_export { augeas_nfs_export { ''/home/server01'': client => ''*.example.com'', options => [''rw'',''sync'',''no_subtree_check'']; } } Now the debug output shows that puppets is producing the right augeas commands and the work in augtool when I run the manually, but I have not been able to get puppet to save /etc/exports Trimed log output from sudo puppetd --test --debug: debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: Changing returns debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: 1 change(s) debug: Augeas[/home/server01](provider=augeas): Opening augeas with root /, lens path , flags 0 debug: Augeas[/home/server01](provider=augeas): sending command ''set'' with params ["/files/etc/exports/dir[.=''/home/server01'']", "''/home/server01''"] debug: Augeas[/home/server01](provider=augeas): sending command ''set'' with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']", "''*.example.com''"] debug: Augeas[/home/server01](provider=augeas): sending command ''remove'' with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option"] debug: Augeas[/home/server01](provider=augeas): sending command ''set'' with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw'']", "''rw''"] debug: Augeas[/home/server01](provider=augeas): sending command ''set'' with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''sync'']", "''sync''"] debug: Augeas[/home/server01](provider=augeas): sending command ''set'' with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''no_subtree_check'']", "''no_subtree_check''"] err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: change from need_to_run to 0 failed: invalid command The first two lines indicate to me that puppet is seeing that on the test run augeas has one line to change in exports, but always fails on the actual run. Also to not is the remove command seems to produce errors on the final run too. if I remove the remove line the error is: err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: change from need_to_run to 0 failed: Save failed with return code false I have tried putting these commands directly into an augeas statement, but it still produces the same errors. Where do I look next? - Karl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bryan Kearney
2009-Apr-07 12:24 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
Just checking if these came out of order. Is this working or not for you? -- bk Karl Bowden wrote:> On Tue, Apr 7, 2009 at 11:46 AM, Karl Bowden <karlbowden@gmail.com> wrote: >> On Mon, Apr 6, 2009 at 11:59 PM, Bryan Kearney <bkearney@redhat.com> wrote: >>> agentk wrote: >>>> I''m not sure if I''m kicking tyres again, but first off: I like the >>>> possibilities with puppet + augeas. >>>> >>>> Trying to make a working example with /etc/exports but not sure of how >>>> to proceed. I want to be able to define exports in the following form: >>>> >>>> my_exports_def { >>>> [''/home/server01'', ''/svr/logs'']: >>>> client => ''*.example.com'', >>>> options => ''rw,sync'', >>>> ''/other/export'': >>>> client => ''*.example.com'', >>>> options => ''rw,sync,no_root_squash'', >>>> } >>>> >>> Try something like this: >>> >>> augeas{"test": >>> context=>"/files/etc/exports", >>> changes => ["set /dir[.=''/home/server01''] ''/home/server01''", >>> "set /dir[.=''/home/server01'']/client ''*.example.com''", >>> "set >>> /dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw''] rw"] >>> >>> } >>> >>> The commands work in augtool. The iteration may be an issue if you have >>> many options. Perhaps you can set that up in a wrapper call and use >>> conditionals? >>> >>> -- bk >> Cheers! Your example did not work at first, but I just needed to >> package the latest augeas for ubuntu. I think that is where half of my >> trouble was. Oh well. All good now thank you. >> >> - Karl >> > > Ok, I''m almost there. But not quite. > > First here is the code I''m using: > > templates/augeas/exports.erb: > set /dir[.=''<%= name %>''] ''<%= name %>'' > set /dir[.=''<%= name %>'']/client[.=''<%= client %>''] ''<%= client %>'' > remove /dir[.=''<%= name %>'']/client[.=''<%= client %>'']/option > <% options.each do |option| %>set /dir[.=''<%= name %>'']/client[.=''<%> client %>'']/option[.=''<%= option %>''] ''<%= option %>'' > <% end %> > > manifests/templates.pp: > define augeas_nfs_export($client=''*'', $options=[''ro'',''sync'']) { > augeas { > "$name": > context => "/files/etc/exports", > changes => template(''augeas/exports.erb''), > } > } > class virt02_export { > augeas_nfs_export { > ''/home/server01'': > client => ''*.example.com'', > options => [''rw'',''sync'',''no_subtree_check'']; > } > } > > Now the debug output shows that puppets is producing the right augeas > commands and the work in augtool when I run the manually, but I have > not been able to get puppet to save /etc/exports > > Trimed log output from sudo puppetd --test --debug: > debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: > Changing returns > debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: > 1 change(s) > debug: Augeas[/home/server01](provider=augeas): Opening augeas with > root /, lens path , flags 0 > debug: Augeas[/home/server01](provider=augeas): sending command ''set'' > with params ["/files/etc/exports/dir[.=''/home/server01'']", > "''/home/server01''"] > debug: Augeas[/home/server01](provider=augeas): sending command ''set'' > with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']", > "''*.example.com''"] > debug: Augeas[/home/server01](provider=augeas): sending command > ''remove'' with params > ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option"] > debug: Augeas[/home/server01](provider=augeas): sending command ''set'' > with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw'']", > "''rw''"] > debug: Augeas[/home/server01](provider=augeas): sending command ''set'' > with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''sync'']", > "''sync''"] > debug: Augeas[/home/server01](provider=augeas): sending command ''set'' > with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''no_subtree_check'']", > "''no_subtree_check''"] > err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: > change from need_to_run to 0 failed: invalid command > > The first two lines indicate to me that puppet is seeing that on the > test run augeas has one line to change in exports, but always fails on > the actual run. > Also to not is the remove command seems to produce errors on the final > run too. if I remove the remove line the error is: > err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: > change from need_to_run to 0 failed: Save failed with return code > false > > I have tried putting these commands directly into an augeas statement, > but it still produces the same errors. Where do I look next? > > - Karl > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Karl Bowden
2009-Apr-07 12:41 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
Sorry, my statements could have been clearer. The example you listed works great in augtool. It was just the syntax I hoped for. It seems that puppet is balking on the /dir[.=''/path''] syntax though. Only on the second augeas run when the changes get applied to the filesystem as the log files correctly state that there is 1 change to apply, but fails to write the change on the second run. It also reports the invalid command error when I include the remove (or rm) statement. So it seems to now be a bug in puppet. I''m just packaging 0.24.8 for ubuntu to retest. I''m currently using: puppet-0.24.7 augeas-0.5.0 libruby-augeas-0.2.0 - Karl On Tue, Apr 7, 2009 at 10:24 PM, Bryan Kearney <bkearney@redhat.com> wrote:> > Just checking if these came out of order. Is this working or not for you? > > -- bk > > Karl Bowden wrote: >> On Tue, Apr 7, 2009 at 11:46 AM, Karl Bowden <karlbowden@gmail.com> wrote: >>> On Mon, Apr 6, 2009 at 11:59 PM, Bryan Kearney <bkearney@redhat.com> wrote: >>>> agentk wrote: >>>>> I''m not sure if I''m kicking tyres again, but first off: I like the >>>>> possibilities with puppet + augeas. >>>>> >>>>> Trying to make a working example with /etc/exports but not sure of how >>>>> to proceed. I want to be able to define exports in the following form: >>>>> >>>>> my_exports_def { >>>>> [''/home/server01'', ''/svr/logs'']: >>>>> client => ''*.example.com'', >>>>> options => ''rw,sync'', >>>>> ''/other/export'': >>>>> client => ''*.example.com'', >>>>> options => ''rw,sync,no_root_squash'', >>>>> } >>>>> >>>> Try something like this: >>>> >>>> augeas{"test": >>>> context=>"/files/etc/exports", >>>> changes => ["set /dir[.=''/home/server01''] ''/home/server01''", >>>> "set /dir[.=''/home/server01'']/client ''*.example.com''", >>>> "set >>>> /dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw''] rw"] >>>> >>>> } >>>> >>>> The commands work in augtool. The iteration may be an issue if you have >>>> many options. Perhaps you can set that up in a wrapper call and use >>>> conditionals? >>>> >>>> -- bk >>> Cheers! Your example did not work at first, but I just needed to >>> package the latest augeas for ubuntu. I think that is where half of my >>> trouble was. Oh well. All good now thank you. >>> >>> - Karl >>> >> >> Ok, I''m almost there. But not quite. >> >> First here is the code I''m using: >> >> templates/augeas/exports.erb: >> set /dir[.=''<%= name %>''] ''<%= name %>'' >> set /dir[.=''<%= name %>'']/client[.=''<%= client %>''] ''<%= client %>'' >> remove /dir[.=''<%= name %>'']/client[.=''<%= client %>'']/option >> <% options.each do |option| %>set /dir[.=''<%= name %>'']/client[.=''<%>> client %>'']/option[.=''<%= option %>''] ''<%= option %>'' >> <% end %> >> >> manifests/templates.pp: >> define augeas_nfs_export($client=''*'', $options=[''ro'',''sync'']) { >> augeas { >> "$name": >> context => "/files/etc/exports", >> changes => template(''augeas/exports.erb''), >> } >> } >> class virt02_export { >> augeas_nfs_export { >> ''/home/server01'': >> client => ''*.example.com'', >> options => [''rw'',''sync'',''no_subtree_check'']; >> } >> } >> >> Now the debug output shows that puppets is producing the right augeas >> commands and the work in augtool when I run the manually, but I have >> not been able to get puppet to save /etc/exports >> >> Trimed log output from sudo puppetd --test --debug: >> debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: >> Changing returns >> debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: >> 1 change(s) >> debug: Augeas[/home/server01](provider=augeas): Opening augeas with >> root /, lens path , flags 0 >> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >> with params ["/files/etc/exports/dir[.=''/home/server01'']", >> "''/home/server01''"] >> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']", >> "''*.example.com''"] >> debug: Augeas[/home/server01](provider=augeas): sending command >> ''remove'' with params >> ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option"] >> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw'']", >> "''rw''"] >> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''sync'']", >> "''sync''"] >> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''no_subtree_check'']", >> "''no_subtree_check''"] >> err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: >> change from need_to_run to 0 failed: invalid command >> >> The first two lines indicate to me that puppet is seeing that on the >> test run augeas has one line to change in exports, but always fails on >> the actual run. >> Also to not is the remove command seems to produce errors on the final >> run too. if I remove the remove line the error is: >> err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: >> change from need_to_run to 0 failed: Save failed with return code >> false >> >> I have tried putting these commands directly into an augeas statement, >> but it still produces the same errors. Where do I look next? >> >> - Karl >> >> > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Karl Bowden
2009-Apr-07 14:49 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
Ok, the error''s are still the same with puppet-0.24.8. But I had to change the way I quoted args in changes lines for it to work. If I use an [.=''somevalue''] def in an augeas changes var in puppet I''m still getting: change from need_to_run to 0 failed: Save failed with return code false I have checked the changes string I am using in augtool again and it saves ok, but the libruby-augeas bindings provide only true and false as options for augeas_save() and no extra information as to what is going wrong. - Karl On Tue, Apr 7, 2009 at 10:41 PM, Karl Bowden <karlbowden@gmail.com> wrote:> Sorry, my statements could have been clearer. > > The example you listed works great in augtool. It was just the syntax > I hoped for. > > It seems that puppet is balking on the /dir[.=''/path''] syntax though. > Only on the second augeas run when the changes get applied to the > filesystem as the log files correctly state that there is 1 change to > apply, but fails to write the change on the second run. > It also reports the invalid command error when I include the remove > (or rm) statement. > > So it seems to now be a bug in puppet. I''m just packaging 0.24.8 for > ubuntu to retest. I''m currently using: > puppet-0.24.7 > augeas-0.5.0 > libruby-augeas-0.2.0 > > - Karl > > On Tue, Apr 7, 2009 at 10:24 PM, Bryan Kearney <bkearney@redhat.com> wrote: >> >> Just checking if these came out of order. Is this working or not for you? >> >> -- bk >> >> Karl Bowden wrote: >>> On Tue, Apr 7, 2009 at 11:46 AM, Karl Bowden <karlbowden@gmail.com> wrote: >>>> On Mon, Apr 6, 2009 at 11:59 PM, Bryan Kearney <bkearney@redhat.com> wrote: >>>>> agentk wrote: >>>>>> I''m not sure if I''m kicking tyres again, but first off: I like the >>>>>> possibilities with puppet + augeas. >>>>>> >>>>>> Trying to make a working example with /etc/exports but not sure of how >>>>>> to proceed. I want to be able to define exports in the following form: >>>>>> >>>>>> my_exports_def { >>>>>> [''/home/server01'', ''/svr/logs'']: >>>>>> client => ''*.example.com'', >>>>>> options => ''rw,sync'', >>>>>> ''/other/export'': >>>>>> client => ''*.example.com'', >>>>>> options => ''rw,sync,no_root_squash'', >>>>>> } >>>>>> >>>>> Try something like this: >>>>> >>>>> augeas{"test": >>>>> context=>"/files/etc/exports", >>>>> changes => ["set /dir[.=''/home/server01''] ''/home/server01''", >>>>> "set /dir[.=''/home/server01'']/client ''*.example.com''", >>>>> "set >>>>> /dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw''] rw"] >>>>> >>>>> } >>>>> >>>>> The commands work in augtool. The iteration may be an issue if you have >>>>> many options. Perhaps you can set that up in a wrapper call and use >>>>> conditionals? >>>>> >>>>> -- bk >>>> Cheers! Your example did not work at first, but I just needed to >>>> package the latest augeas for ubuntu. I think that is where half of my >>>> trouble was. Oh well. All good now thank you. >>>> >>>> - Karl >>>> >>> >>> Ok, I''m almost there. But not quite. >>> >>> First here is the code I''m using: >>> >>> templates/augeas/exports.erb: >>> set /dir[.=''<%= name %>''] ''<%= name %>'' >>> set /dir[.=''<%= name %>'']/client[.=''<%= client %>''] ''<%= client %>'' >>> remove /dir[.=''<%= name %>'']/client[.=''<%= client %>'']/option >>> <% options.each do |option| %>set /dir[.=''<%= name %>'']/client[.=''<%>>> client %>'']/option[.=''<%= option %>''] ''<%= option %>'' >>> <% end %> >>> >>> manifests/templates.pp: >>> define augeas_nfs_export($client=''*'', $options=[''ro'',''sync'']) { >>> augeas { >>> "$name": >>> context => "/files/etc/exports", >>> changes => template(''augeas/exports.erb''), >>> } >>> } >>> class virt02_export { >>> augeas_nfs_export { >>> ''/home/server01'': >>> client => ''*.example.com'', >>> options => [''rw'',''sync'',''no_subtree_check'']; >>> } >>> } >>> >>> Now the debug output shows that puppets is producing the right augeas >>> commands and the work in augtool when I run the manually, but I have >>> not been able to get puppet to save /etc/exports >>> >>> Trimed log output from sudo puppetd --test --debug: >>> debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: >>> Changing returns >>> debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: >>> 1 change(s) >>> debug: Augeas[/home/server01](provider=augeas): Opening augeas with >>> root /, lens path , flags 0 >>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>> with params ["/files/etc/exports/dir[.=''/home/server01'']", >>> "''/home/server01''"] >>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']", >>> "''*.example.com''"] >>> debug: Augeas[/home/server01](provider=augeas): sending command >>> ''remove'' with params >>> ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option"] >>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw'']", >>> "''rw''"] >>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''sync'']", >>> "''sync''"] >>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''no_subtree_check'']", >>> "''no_subtree_check''"] >>> err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: >>> change from need_to_run to 0 failed: invalid command >>> >>> The first two lines indicate to me that puppet is seeing that on the >>> test run augeas has one line to change in exports, but always fails on >>> the actual run. >>> Also to not is the remove command seems to produce errors on the final >>> run too. if I remove the remove line the error is: >>> err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: >>> change from need_to_run to 0 failed: Save failed with return code >>> false >>> >>> I have tried putting these commands directly into an augeas statement, >>> but it still produces the same errors. Where do I look next? >>> >>> - Karl >>> >>> > >> >> >> >> >> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Karl Bowden
2009-Apr-08 01:49 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
Ok I''ve got it sorted now and I''ll submit the recipe to the wiki after somebody here reviews it as I''m only new to puppet. After writing tests in ruby with the libaugeas-ruby bindings it turns out the problem is that the bindings do not like set values to be quoted. Works: set \"/dir[.=''<%= name %>'']\" <%= name %> Does not work: set \"/dir[.=''<%= name %>'']\" ''<%= name %>'' Template: define augeas_nfs_export($client=''*'', $options=[''ro'',''sync'']) { $exports_template = "set \"/dir[.=''<%= name %>'']\" ''<%= name %>'' set \"/dir[.=''<%= name %>'']/client[.=''<%= client %>'']\" ''<%= client %>'' remove \"/dir[.=''<%= name %>'']/client[.=''<%= client %>'']/option\" <% options.each do |option| %>set \"/dir[.=''<%= name %>'']/client[.=''<%= client %>'']/option[.=''<%= option %>'']\" ''<%= option %>'' <% end %>" augeas { "etc_exports_${name}": context => "/files/etc/exports", changes => inline_template($exports_template) } } Usage: class my_export { augeas_nfs_export { ''/home/server01'': client => ''*.example.com'', options => [''rw'',''sync'',''no_subtree_check'']; ''/svr/backups'': client => ''*.example.com'', options => [''rw'',''sync'',''no_subtree_check'',''no_root_squash'']; ''/svr/backups'': client => ''*.another.domain.com'', options => [''ro'',''sync'']; } } Any suggestions? Ps: Cant express how pleasurable puppet + augeas is now too! Regards, Karl On Wed, Apr 8, 2009 at 12:49 AM, Karl Bowden <karlbowden@gmail.com> wrote:> Ok, the error''s are still the same with puppet-0.24.8. But I had to > change the way I quoted args in changes lines for it to work. > > If I use an [.=''somevalue''] def in an augeas changes var in puppet I''m > still getting: change from need_to_run to 0 failed: Save failed with > return code false > > I have checked the changes string I am using in augtool again and it > saves ok, but the libruby-augeas bindings provide only true and false > as options for augeas_save() and no extra information as to what is > going wrong. > > - Karl > > On Tue, Apr 7, 2009 at 10:41 PM, Karl Bowden <karlbowden@gmail.com> wrote: >> Sorry, my statements could have been clearer. >> >> The example you listed works great in augtool. It was just the syntax >> I hoped for. >> >> It seems that puppet is balking on the /dir[.=''/path''] syntax though. >> Only on the second augeas run when the changes get applied to the >> filesystem as the log files correctly state that there is 1 change to >> apply, but fails to write the change on the second run. >> It also reports the invalid command error when I include the remove >> (or rm) statement. >> >> So it seems to now be a bug in puppet. I''m just packaging 0.24.8 for >> ubuntu to retest. I''m currently using: >> puppet-0.24.7 >> augeas-0.5.0 >> libruby-augeas-0.2.0 >> >> - Karl >> >> On Tue, Apr 7, 2009 at 10:24 PM, Bryan Kearney <bkearney@redhat.com> wrote: >>> >>> Just checking if these came out of order. Is this working or not for you? >>> >>> -- bk >>> >>> Karl Bowden wrote: >>>> On Tue, Apr 7, 2009 at 11:46 AM, Karl Bowden <karlbowden@gmail.com> wrote: >>>>> On Mon, Apr 6, 2009 at 11:59 PM, Bryan Kearney <bkearney@redhat.com> wrote: >>>>>> agentk wrote: >>>>>>> I''m not sure if I''m kicking tyres again, but first off: I like the >>>>>>> possibilities with puppet + augeas. >>>>>>> >>>>>>> Trying to make a working example with /etc/exports but not sure of how >>>>>>> to proceed. I want to be able to define exports in the following form: >>>>>>> >>>>>>> my_exports_def { >>>>>>> [''/home/server01'', ''/svr/logs'']: >>>>>>> client => ''*.example.com'', >>>>>>> options => ''rw,sync'', >>>>>>> ''/other/export'': >>>>>>> client => ''*.example.com'', >>>>>>> options => ''rw,sync,no_root_squash'', >>>>>>> } >>>>>>> >>>>>> Try something like this: >>>>>> >>>>>> augeas{"test": >>>>>> context=>"/files/etc/exports", >>>>>> changes => ["set /dir[.=''/home/server01''] ''/home/server01''", >>>>>> "set /dir[.=''/home/server01'']/client ''*.example.com''", >>>>>> "set >>>>>> /dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw''] rw"] >>>>>> >>>>>> } >>>>>> >>>>>> The commands work in augtool. The iteration may be an issue if you have >>>>>> many options. Perhaps you can set that up in a wrapper call and use >>>>>> conditionals? >>>>>> >>>>>> -- bk >>>>> Cheers! Your example did not work at first, but I just needed to >>>>> package the latest augeas for ubuntu. I think that is where half of my >>>>> trouble was. Oh well. All good now thank you. >>>>> >>>>> - Karl >>>>> >>>> >>>> Ok, I''m almost there. But not quite. >>>> >>>> First here is the code I''m using: >>>> >>>> templates/augeas/exports.erb: >>>> set /dir[.=''<%= name %>''] ''<%= name %>'' >>>> set /dir[.=''<%= name %>'']/client[.=''<%= client %>''] ''<%= client %>'' >>>> remove /dir[.=''<%= name %>'']/client[.=''<%= client %>'']/option >>>> <% options.each do |option| %>set /dir[.=''<%= name %>'']/client[.=''<%>>>> client %>'']/option[.=''<%= option %>''] ''<%= option %>'' >>>> <% end %> >>>> >>>> manifests/templates.pp: >>>> define augeas_nfs_export($client=''*'', $options=[''ro'',''sync'']) { >>>> augeas { >>>> "$name": >>>> context => "/files/etc/exports", >>>> changes => template(''augeas/exports.erb''), >>>> } >>>> } >>>> class virt02_export { >>>> augeas_nfs_export { >>>> ''/home/server01'': >>>> client => ''*.example.com'', >>>> options => [''rw'',''sync'',''no_subtree_check'']; >>>> } >>>> } >>>> >>>> Now the debug output shows that puppets is producing the right augeas >>>> commands and the work in augtool when I run the manually, but I have >>>> not been able to get puppet to save /etc/exports >>>> >>>> Trimed log output from sudo puppetd --test --debug: >>>> debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: >>>> Changing returns >>>> debug: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]: >>>> 1 change(s) >>>> debug: Augeas[/home/server01](provider=augeas): Opening augeas with >>>> root /, lens path , flags 0 >>>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>>> with params ["/files/etc/exports/dir[.=''/home/server01'']", >>>> "''/home/server01''"] >>>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>>> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']", >>>> "''*.example.com''"] >>>> debug: Augeas[/home/server01](provider=augeas): sending command >>>> ''remove'' with params >>>> ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option"] >>>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>>> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''rw'']", >>>> "''rw''"] >>>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>>> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''sync'']", >>>> "''sync''"] >>>> debug: Augeas[/home/server01](provider=augeas): sending command ''set'' >>>> with params ["/files/etc/exports/dir[.=''/home/server01'']/client[.=''*.example.com'']/option[.=''no_subtree_check'']", >>>> "''no_subtree_check''"] >>>> err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: >>>> change from need_to_run to 0 failed: invalid command >>>> >>>> The first two lines indicate to me that puppet is seeing that on the >>>> test run augeas has one line to change in exports, but always fails on >>>> the actual run. >>>> Also to not is the remove command seems to produce errors on the final >>>> run too. if I remove the remove line the error is: >>>> err: //Node[virt02.nugan.com.au]/virt02_export/Augeas_nfs_export[/home/server01]/Augeas[/home/server01]/returns: >>>> change from need_to_run to 0 failed: Save failed with return code >>>> false >>>> >>>> I have tried putting these commands directly into an augeas statement, >>>> but it still produces the same errors. Where do I look next? >>>> >>>> - Karl >>>> >>>> > >>> >>> >>> >>> >>> >> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bryan Kearney
2009-Apr-08 12:03 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
Karl Bowden wrote:> Ok I''ve got it sorted now and I''ll submit the recipe to the wiki after > somebody here reviews it as I''m only new to puppet. > > After writing tests in ruby with the libaugeas-ruby bindings it turns > out the problem is that the bindings do not like set values to be > quoted. > > Works: > set \"/dir[.=''<%= name %>'']\" <%= name %> > > Does not work: > set \"/dir[.=''<%= name %>'']\" ''<%= name %>''Are these commands in augtool or commands in puppet? I want to see if the puppet type is causing issues not in augtool. -- 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 -~----------~----~----~----~------~----~------~--~---
Avi Miller
2009-Apr-08 21:30 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
Bryan, Bryan Kearney wrote:> Are these commands in augtool or commands in puppet? I want to see if > the puppet type is causing issues not in augtool.Could it be related to this bug I logged: http://projects.reductivelabs.com/issues/2141 Thanks, Avi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Lutterkort
2009-Apr-08 21:39 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Wed, 2009-04-08 at 08:03 -0400, Bryan Kearney wrote:> Karl Bowden wrote: > > Ok I''ve got it sorted now and I''ll submit the recipe to the wiki after > > somebody here reviews it as I''m only new to puppet. > > > > After writing tests in ruby with the libaugeas-ruby bindings it turns > > out the problem is that the bindings do not like set values to be > > quoted. > > > > Works: > > set \"/dir[.=''<%= name %>'']\" <%= name %> > > > > Does not work: > > set \"/dir[.=''<%= name %>'']\" ''<%= name %>'' > > Are these commands in augtool or commands in puppet? I want to see if > the puppet type is causing issues not in augtool.I _think_ there''s an issue with how the augeas type is parsing commands from the changes property (see ticket #2141) To fix that, the mini-language for the changes property needs to be backed by a slightly more robust ''parser''; I think it should be told explicitly the arguments that commands take, and scan them slightly differently for paths and for strings. I attached a little standalone program that does the scanning right (I''ll also attach that to ticket #2141) 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 -~----------~----~----~----~------~----~------~--~---
David Lutterkort
2009-Apr-08 21:46 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Wed, 2009-04-08 at 14:39 -0700, David Lutterkort wrote:> I attached a little standalone > program that does the scanning right (I''ll also attach that to ticket > #2141)Now with 100% more attachments. 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 -~----------~----~----~----~------~----~------~--~---
Avi Miller
2009-Apr-08 21:54 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
David Lutterkort wrote:>> I attached a little standalone >> program that does the scanning right (I''ll also attach that to ticketDavid -- am I supposed to do something with this attachment? :) Ta, Avi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Karl Bowden
2009-Apr-08 22:25 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
After a little testing, the problem is occuring directly in libruby-augeas. I get the same save file errors when trying to save a file after making changes and using quotes inside quotes. But the issue does not happen in augtool, but that may just be the way i''m using augtool. I am sure it has something to do with the way I am using the index searech ([.=''/path'']), but I am still working up an example to demonstrate with. - Karl On Thu, Apr 9, 2009 at 7:54 AM, Avi Miller <avi.miller@gmail.com> wrote:> > > > David Lutterkort wrote: >>> I attached a little standalone >>> program that does the scanning right (I''ll also attach that to ticket > > David -- am I supposed to do something with this attachment? :) > > Ta, > Avi > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Lutterkort
2009-Apr-08 23:53 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Thu, 2009-04-09 at 07:54 +1000, Avi Miller wrote:> > > David Lutterkort wrote: > >> I attached a little standalone > >> program that does the scanning right (I''ll also attach that to ticket > > David -- am I supposed to do something with this attachment? :)Somebody (not necesarily you, and I''d do it if I had time for it) needs to take the parse_commands method in there and replace the one in the current Augeas provider with it; also, we should have a way to unit test how commands are parsed. 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 -~----------~----~----~----~------~----~------~--~---
Avi Miller
2009-Apr-08 23:54 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
David Lutterkort wrote:> Somebody (not necesarily you, and I''d do it if I had time for it) needs > to take the parse_commands method in there and replace the one in the > current Augeas provider with it;I suspect the someone should have some experience with Ruby, unlike myself. :) I shall wait patiently for someone (else) to do it. Ta, Avi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Lutterkort
2009-Apr-08 23:58 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Thu, 2009-04-09 at 08:25 +1000, Karl Bowden wrote:> After a little testing, the problem is occuring directly in > libruby-augeas. I get the same save file errors when trying to save a > file after making changes and using quotes inside quotes. But the > issue does not happen in augtool, but that may just be the way i''m > using augtool.My very strong suspicion is that you are running into a similar problem with quoting that Avi reported in ticket #2141, and that what happens is that the changes string gets split incorrectly, so that what is sent to ruby-augeas are actually malformed commands.> I am sure it has something to do with the way I am using the index > searech ([.=''/path'']), but I am still working up an example to > demonstrate with.That would be excellent, since frankly, I am getting a little lost in this thread ... 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 -~----------~----~----~----~------~----~------~--~---
Karl Bowden
2009-Apr-09 00:44 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Thu, Apr 9, 2009 at 9:58 AM, David Lutterkort <lutter@redhat.com> wrote:> > On Thu, 2009-04-09 at 08:25 +1000, Karl Bowden wrote: >> After a little testing, the problem is occuring directly in >> libruby-augeas. I get the same save file errors when trying to save a >> file after making changes and using quotes inside quotes. But the >> issue does not happen in augtool, but that may just be the way i''m >> using augtool. > > My very strong suspicion is that you are running into a similar problem > with quoting that Avi reported in ticket #2141, and that what happens is > that the changes string gets split incorrectly, so that what is sent to > ruby-augeas are actually malformed commands. > >> I am sure it has something to do with the way I am using the index >> searech ([.=''/path'']), but I am still working up an example to >> demonstrate with. > > That would be excellent, since frankly, I am getting a little lost in > this thread ... >That''s ok, turns out I was wrong again! Oh, and my problem is not the ticket #2141. Although it would be nice to get that behaviour reverted I have already worked around it by escape quoting all paths I use. I''ve only been learning enough ruby for two days just to test the augeas bindings, so mind the quality. Attached is a bindings demo that shows how the bindings handle quotes, and the output is below: libruby-augeas test sample root = /files/etc/exports rm /dir[1] : 3 set /dir[1] /home/server : true : /home/server set /dir[1]/client *.example.com : true : *.example.com set /dir[1]/client/option rw : true : rw save : true set /dir[1] ''/home/server'' : true : ''/home/server'' set /dir[1]/client ''*.example.com'' : true : ''*.example.com'' set /dir[1]/client/option ''rw'' : true : ''rw'' save : false Puppet does the right thing by sending the values to the augeas binding as they are given to puppet. And the augeas binding although not nessecaraly wrong, differs from how augtool handles the same example: ~/ augtool -r /tmp augtool> print /files/etc/exports augtool> set /files/etc/exports/dir[1] /home/server augtool> set /files/etc/exports/dir[1]/client *.example.com augtool> set /files/etc/exports/dir[1]/client/option rw augtool> print /files/etc/exports/ /files/etc/exports /files/etc/exports/dir = "/home/server" /files/etc/exports/dir/client = "*.example.com" /files/etc/exports/dir/client/option = "rw" augtool> set /files/etc/exports/dir[1] ''/home/server'' augtool> set /files/etc/exports/dir[1]/client ''*.example.com'' augtool> set /files/etc/exports/dir[1]/client/option ''rw'' augtool> print /files/etc/exports/ /files/etc/exports /files/etc/exports/dir = "/home/server" /files/etc/exports/dir/client = "*.example.com" /files/etc/exports/dir/client/option = "rw" augtool> save Saved 1 file(s) augtool> Hopefully that will make it clearer what I am talking about. This does not appear to be a problem with puppet, but something people will have to be aware of if using puppet+augeas. - Karl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bryan Kearney
2009-Apr-09 15:54 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
Avi Miller wrote:> > > David Lutterkort wrote: >> Somebody (not necesarily you, and I''d do it if I had time for it) needs >> to take the parse_commands method in there and replace the one in the >> current Augeas provider with it; > > I suspect the someone should have some experience with Ruby, unlike > myself. :) I shall wait patiently for someone (else) to do it. >I took David''s patch (Thanks David!) and integrated it into the type. You can either build puppet from source by cloning off of my repo: http://github.com/bkearney/puppet/tree/ticket/0.24.x/2441 Or you can apply this patch. You should be able to apply it from the site_ruby directory. There are a couple of subtle changes to the type based on this patch. I believe them to be for the better, but they may bite you: 1) There can be no '' or " characters around path elements. 2) The context is now only prepended to relative paths. So, if a path is specified as /foo/bar the context will not be appended. It will only be appended if it is foo/bar 3) The syntax for array matching in the onlyif is now eq or noteq. It was == before. 4) The get and set commnands used to concatenate all items at the end of a string so "set path to some value" would be interpreted as "set" "path" "to some value". This is no longer supported. The caller must put '' or " around the "to some value" for it to work" Let me know if you have any issues. -- 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 -~----------~----~----~----~------~----~------~--~---
David Lutterkort
2009-Apr-09 23:51 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Thu, 2009-04-09 at 10:44 +1000, Karl Bowden wrote:> I''ve only been learning enough ruby for two days just to test the > augeas bindings, so mind the quality.Kudos to you :)> Attached is a bindings demo that shows how the bindings handle quotes, > and the output is below:The ruby bindings just pass the strings they get from Ruby through to the C library - they never try to interpret anything they see in those strings, and the results of your tests clearly show that.> And the augeas binding although not nessecaraly wrong, differs from > how augtool handles the same example:Therein lies the rub - augtool reads a line from the terminal (or a file) and needs to split it into individual tokens, similar to how the augeas provider does it, except it''s much cruftier. I intend to make augtool to behave identical to the augeas provider to minimize confusion around quoting and all that when you go back and forth between trying things out in augtool and putting them into pupet manifests. 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 -~----------~----~----~----~------~----~------~--~---
Karl Bowden
2009-Apr-10 08:49 UTC
[Puppet Users] Re: puppet + augeas /etc/exports/dir[*] lookup possible?
On Fri, Apr 10, 2009 at 9:51 AM, David Lutterkort <lutter@redhat.com> wrote:> > On Thu, 2009-04-09 at 10:44 +1000, Karl Bowden wrote: >> I''ve only been learning enough ruby for two days just to test the >> augeas bindings, so mind the quality. > > Kudos to you :) > >> Attached is a bindings demo that shows how the bindings handle quotes, >> and the output is below: > > The ruby bindings just pass the strings they get from Ruby through to > the C library - they never try to interpret anything they see in those > strings, and the results of your tests clearly show that. > >> And the augeas binding although not nessecaraly wrong, differs from >> how augtool handles the same example: > > Therein lies the rub - augtool reads a line from the terminal (or a > file) and needs to split it into individual tokens, similar to how the > augeas provider does it, except it''s much cruftier. > > I intend to make augtool to behave identical to the augeas provider to > minimize confusion around quoting and all that when you go back and > forth between trying things out in augtool and putting them into pupet > manifests. > > David@David: I am quite happy with the way augtool parses commands and the changes in the patch from Bryan now also make puppet more ''intelligent''. I think that both the bindings and puppet do the right things, and am happy either way for the parsing in augtool. The way augtool operates currently seems most natural. @Bryan: I have attached a patch too, to be applied yours as I liked the previous string trimming. It just made it easier to have more readable puppet manifests and I cant really see any detriment to the strips. You have made the right choices and requirements in your patch IMHO. It makes augeas functions easier to read and the results more predictable. I have applied both patches to my 0.24.8 packages and finished deployment without detriment. Thank you all, Karl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---