> Truth be told, I never thought people would use augeas directly through
> the augeas type; I always thought augeas would be used to write puppet
> types in ruby more easily. For more complicated abstractions, that's
> what you might have to resort to - of course, there's nothing wrong
> with using the augeas type directly for the cases where it is adequate.

I'm more a Perler than Rubyer, so easier to write new classes and definitions 
over the top of the Augeas type in Puppet.  Still, in many cases it's not 
necessary to resort to Augeas for simple config files, an Exec with an 'unless' 
works equally well (and faster).

> > In the meantime, I've created lens files for MRTG/Routers2 config
> files.
> 
> Cool - did I miss the patches flying by ? ;)

They're still going through a bit of testing, then I was going to post them to 
the MRTG project, since they are tied in with Puppet modules.  Managing MRTG 
via Augeas is a bit painful (due to the previously mentioned key precedence 
issue) and Puppet modules with Exec's of cfgmaker with appropriate templates 
and so on work better in many cases.  

However I'm happy to pass them on to the Augeas project.

Steve

Routers2.aug
----------------
(* routers2.conf module for Augeas                    *)
module Routers2 =
  autoload xfm
let comment  = IniFile.comment "#" "#"
let sep      = IniFile.sep /[ \t]*=[ \t]*/ " = "
let value  = (  Util.del_opt_ws "" . store /[^\n]*/ )
let entry_re = ( /[a-zA-Z0-9_\.-]+/ )
let var_entry =  [ key entry_re . sep . value . IniFile.eol ]
let path_entry =  [ label "path" . [ label "path" . Util.del_opt_ws "" . store 
/\/[A-Za-z0-9_\.\:\/-]+/ ] . sep . [ label "value" . value . IniFile.eol ] ]
let entry    = var_entry | path_entry | comment
let title   = IniFile.title IniFile.record_re
let record  = IniFile.record title entry
let lns    = IniFile.lns record comment
let filter = incl "/u01/etc/routers2.conf" . incl "routers2.conf" . Util.stdexcl
let xfm = transform lns filter
------------------
MRTG.aug
------------------
module MRTG =
  autoload xfm
(* MRTG configuration file Augeas lens
Possible formats:
directive: value
directive[target]: value
external*directive: value
external*directive[target]: value
Options[target]: value value value ...
 continuationline
# comment
blankline
*)
let obrkt = del /\[/ "["
let cbrkt = del /\]/ "]"
let nl = del /\n/ "\n"
let sep = del /[ \t]*:[ \t]*/ ": "
(* this should be able to handle continuation lines *)
let val = store /([^ \t\n][^\n]*|)(\n[ \t]+[^\n]*)*/ . nl
let comment = [ label "#comment" . del /^#/ "#" . store /[^\n]*/ . nl ]
let empty = Util.empty
let global = [ key /[a-zA-Z0-9]+/ . sep . val ]
let externglobal = [ key /[^ \t\n\/\*]+/ . del /\*/ "*" . global ]
let target = [ key /[a-zA-Z0-9]+/ . del / */ "" . [ obrkt . key 
/([a-zA-Z0-9_\.-]+|_|\$|\^)/ . cbrkt . sep . val ] ]
let externtarget = [ key /[^ \t\n\/\*]+/ . del /\*/ "*" . target ]
let lns = ( global | target | externglobal | externtarget | comment | empty ) *
let filter = Util.stdexcl .
    incl "/etc/mrtg/conf/*.cfg" . incl "/usr/local/mrtg*/conf/*.cfg" 
let xfm = transform lns filter
---------------

Steve Shipway
[email protected]
Routers2.cgi web frontend for MRTG/RRD; NagEventLog Nagios agent for Windows 
Event Log monitoring; check_vmware plugin for VMWare monitoring in Nagios and 
MRTG; and other Open Source projects.
Web: http://www.steveshipway.org/software
 Please consider the environment before printing this e-mail 




_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to