Kristian Glass - Do I Smell Burning?

Mostly technical things

Augeas

Let me tell you a story about a call that changed my destiny tool that I find really useful.

To quote the website, “Augeas is a configuration editing tool. It parses configuration files in their native formats and transforms them into a tree. Configuration changes are made by manipulating this tree and saving it back into native config files”.

So you’re scripting some machine config and want to ensure some bits of config? Replace things like this:

echo “AllowTcpForwarding yes” >> /etc/ssh/sshd_config

or this:

sed -i ’s/^AllowTcpForwarding.*no/AllowTcpForwarding yes/‘ /etc/sshd/sshd_config

with the much nicer:

augtool set /files/etc/ssh/sshd_config/AllowTcpForwarding yes

The first two examples both make some significant and potentially-invalid assumptions about the contents of sshd_config – yes you can write them more intelligently, grepping first etc., but why reinvent the wheel?

The quick tour documentation is rather nice, and also illustrates the matching ability for finding the “paths”. I was interested to note that the schemas (“lenses”) are written in “a very small subset of ML” - a language I haven’t really touched since I was an undergrad, but that appears to have come back to me with remarkable ease! Writing a lens looks mildly nontrivial, especially compared to Augeas’s general ease of use, but I’ve had no cause to actually do so yet, so this is based on limited data.

Bindings exist for Python, Ruby, Java, PHP and more, so there’s no need to hack around with os.system or similar!

In summary, a most excellent tool for any kind of config file editing – it’ll save you a lot of pain and is far more readable and maintainable. Enjoy.

(Inspired by some of the responses to a comment of mine on Reddit suggesting that this great tool could do with being a bit better known!)