augtool Augeas seams to be a popular program for Puppet to modify config files, but how do I modify a config file where augtool doesn't have a lense for? E.g.:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Compiz
Exec=compiz
NoDisplay=false
# name of loadable control center module
X-GNOME-WMSettingsModule=metacity

In this particular example would I like to change NoDisplay to true.

Question

Is it possible to modify config files without a lense? Can augtool try to guess the tree structure of a config file?

有帮助吗?

解决方案

Augeas cannot guess which lens to use. For example, in the case of a Desktop file (your example), many lenses could be used (MySQL.lns, PHP.lns, etc.) but each of them would introduce restrictions that would not be compatible with the Desktop format.

In your case, you want to use the Desktop.lns lens:

$ augtool --autosave --noautoload --transform "Desktop.lns incl /path/to/your/example.desktop" set "/files/path/to/your/example.desktop/Desktop Entry/NoDisplay" true

其他提示

No, augeas is not able to operate without a suitable lense. (Adding those is supposedly pretty difficult, too).

Your example looks like a pretty common ini type config file, though. Have you tried the IniFile lens?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top