David Lutterkort wrote:

> On Tue, 2008-12-16 at 09:52 +0100, Thomas Bellman wrote:

>> 1. Is it possible to specify what lens to use for editing a
>>     certain file?  Can I for instance tell it to use the sshd lens
>>     to edit an sshd config file in a non-standard place?
> 
> Add the directory with your custom lens to the load_path; augeas will
> then load that lens instead of the default one.
> 
>>   Or to
>>     use the shellvars lens to edit /etc/sysconfig/sendmail (the
>>     version of Augeas in Fedora 9 happily edits lots of other
>>     files in /etc/sysconfig, but not the sendmail file).  Do I
>>     have to write a new lens for this?
> 
> That was an oversight; I just comitted a fix to add that file in
> shellvars.aug.
> 
> For now, you can work around that by adding a module like
>         module Sendmail
>           autoload xfm
>         
>           let xfm = transform Shellvars.lns (incl "/etc/sysconfig/sendmail")
> 

As I feared.  At least I don't have to maintain full copies of the sshd
or shellvars lenses.  Still, it would be very nice to be able to just tell
augeas to use a specific lens for a specific file, without having to
write a custom lens (even if a very small one).  In Puppet, I think a good
interface would be something like:

     augeas {
        globus-sshd-hostauth:
            file => "/opt/globus/etc/ssh/sshd_config",
            lens => "sshd",
            changes => [ "set /HostbasedAuthentication yes" ];
     }

to tell Augeas to use the normal sshd lens when editing the file
/opt/globus/etc/ssh/sshd_config.  That would make it much more
convenient to use.  (Yes, I know I can use the root parameter in
this specific case, but I hope you see the principle beyond my
example.  I'm quite confident that I will *always* be able to find
an /etc/sysconfig file from an obscure package that you haven't
yet added to shellvars.aug. :-)


>> [...About removing the "rhgb" words from kernel lines in grub.conf...]

> Yeah, that is a problem. It's not quite a solution, but to allow such
> operations we'd need to change the grub lens to split the kernel line
> into individual arguments, so that you get something like
> 
>         /files/etc/grub.conf/title[1]/kernel = 
> "/vmlinuz-2.6.27.5-41.fc9.x86_64"
>         /files/etc/grub.conf/title[1]/kernel/arg = "ro"
>         /files/etc/grub.conf/title[1]/kernel/arg = "root=/dev/sda2"
>         /files/etc/grub.conf/title[1]/kernel/arg = "rhgb"
>         /files/etc/grub.conf/title[1]/kernel/arg = "quiet"
>         
> Right now, you're still stuck even with that - I am working on extending
> the query language so that you could remove the "rhgb" arg with
> something like
> 
>         rm /files/etc/grub.conf/title/kernel[value() = 
> "/vmlinuz-2.6.27.5-41.fc9.x86_64"]/arg[value() = "rhgb"]
>        
> and do the same for all kernels with 
> 
>         rm /files/etc/grub.conf/title/kernel/arg[value() = "rhgb"]            
>  
>         
> but unfortunately, that isn't quite finished yet.

Another alternative might be to be able to do regexp replacements on
values.  Something like

     transform .../title[1]/kernel "vmlinuz-(.*) rhgb(.*)" "vmlinuz-\\1\\2"

Something like that could be useful even with your arg[value()==...]
extension above.  There will probably *always* be cases where the
tree created by Augeas is not quite enough.

(However, we then get to the joys of applying three levels of quoting: one
for string literals in Puppet, one for string literals in Augeas, and one
for regexps.  It's bad enough that we have already have the two first levels
to deal with.  I believe we need to think a bit more about what syntax we
want in Puppet for Augeas.)


> That will also require the XPath extension I am working on, so that you
> can say
> 
>         rm /files/etc/logrotate.conf/rule[file = "/var/log/wtmp"]

OK.  I'm looking forward to that, then.


Luckily for me, I have already solved my current file editing needs, with a
couple of custom Puppet types that do regexp-based line editing.  But it will
be nice to be able to do all I want without resorting to custom extensions.
In many cases, using Augeas will be a much cleaner way to do what I want,
also.

Keep up the good work!


        /Bellman

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to