hercules-team / augeas-do-not-use

A configuration editing tool and API
http://augeas.net/
GNU Lesser General Public License v2.1
24 stars 9 forks source link

Add conditionality to config file locations in lenses #16

Open thejoecarroll opened 11 years ago

thejoecarroll commented 11 years ago

I'd like to see the included lens descriptions check what OS Augeas is running on and then choose the appropriate location. For example, "out of the box" Augeas will not process sshdconfig on Mac OS X because it is not located at the same path as on Ubuntu. It is necesary to edit .../share/augeas/lenses/dist/sshd.aug_ so that the line let xfm = transform lns (incl "/etc/ssh/sshd_config") becomes: let xfm = transform lns (incl "/etc/sshd_config") I'm not really familiar with ML and only just discovered Augeas and haven't read up too much yet on the lens DSL (so pardon me if this is already possible), but it seems like adding some sort of environment variable that a lens can check along with support for conditional structures along the lines of switch/case statements in other languages would do the trick.

raphink commented 11 years ago

Unfortunately, it is not possible to check for the OS in the lens.

However, it is possible to parse both /etc/ssh/sshd_config and /etc/sshd_config if they exist. A lot of lenses parse several files. Have a look at xinetd.aug for example.

giraldeau commented 11 years ago

It makes me think of a quote from a old unix guy that said me a software evolves until it has a ".d" directory. In fact, could it be possible to override transforms by adding files in some directory? That would increase the convenience to ship for various distributions, and still ship default lens set.

raphink commented 11 years ago

Some time ago, @lutter, @domcleal and I (I think) were talking about adding runtime parameters to lenses, to be set in /augeas. That was one of the use cases if my memory is not failing.