[augeas-devel] How to use the generic IniFile module?

Biltong biltong at fastmail.fm
Mon Mar 5 15:07:54 UTC 2012


On Mon, Mar 5, 2012, at 10:29 AM, Dominic Cleal wrote:
> On 05/03/12 09:32, Biltong wrote:
> > Hello,
> > 
> > Is it possible to list all lenses that Augeas supports?
> 
> Looking in /usr/share/augeas/lenses/dist is probably your best bet.
> Most of the modules have a "lns" lens inside, except where they're
> designed as building blocks (e.g. util, rx, build and inifile).
> 
> There's also the generated documentation, but it doesn't list all
> lenses, as documentation coverage isn't complete yet:
> 
> http://augeas.net/docs/references/lenses/

Thanks. The ability for augtool to list lenses would still be nice
though. Should I file an RFE?

> > I'd like to edit a .ini file without defining a new lens. When I try, I
> > get an error:
> > 
> > augtool> set /augeas/load/IniFile/lens inifile
> > augtool> set /augeas/load/IniFile/incl /some/file.ini
> > augtool> load
> > error: Lens not found
> > error: Can not find lens inifile
> > 
> > I can see a inifile.aug in /usr/share/augeas/lenses/dist
> > 
> > What's going on? Thanks.
> 
> Two things here:
> 
> a) The IniFile module is a set of building blocks and doesn't contain a
> lens that will let you parse a whole file.  The reason for this is .ini
> files actually vary somewhat in design, so there's no single generic
> lens it provides.
> 
> You'd be better off specifying one of the derived lenses, such as:
> 
> Puppet.lns - simple .ini file
> PHP.lns - allows settings outside of sections (under ".anon")
> MySQL.lns - allows slashes in section names, supports !include etc
> Dput.lns - allows only certain setting names, allows slashes
> 
> For a many cases, Puppet.lns is probably suitable.

Okay. And what's the best way of distributing lenses, if I create new
ones? Putting them somewhere not in /dist sounds sensible, is that
right?

> b) The "lens" setting should usually be "ModuleName.lns" rather than the
> filename "inifile".
> 
> So for the puppet.aug file, the "module Puppet" line inside gives you
> the module name "Puppet".   The lens inside puppet.aug that represents
> the entire config is by convention called "lns" (see the "transform"
> line near the bottom), so you instead need to run:
> 
> set /augeas/load/IniFile/lens Puppet.lns
> 
> Hope that helps.

Yes, thanks.

> 
> -- 
> Dominic Cleal
> Red Hat Consulting
> m: +44 (0)7817 878113
> 
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel
> 

-- 
http://www.fastmail.fm - The way an email service should be




More information about the augeas-devel mailing list