augeas-do-not-use icon indicating copy to clipboard operation
augeas-do-not-use copied to clipboard

Add conditionality to config file locations in lenses

Open thejoecarroll opened this issue 12 years ago • 3 comments

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 sshd_config 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.

thejoecarroll avatar Feb 12 '13 13:02 thejoecarroll

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.

raphink avatar Feb 12 '13 13:02 raphink

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.

giraldeau avatar Feb 12 '13 13:02 giraldeau

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.

raphink avatar Feb 12 '13 14:02 raphink