Main Contents

Augeas

Planet Debian, Planet Ubuntu

I’ve been writing a lot about Augeas and all the process i go through to get it included in debian/ubuntu. It seems that a lot of people was following it, but some of them don’t actually understand the whole picture and what is augeas for, so i’ve been asked to write a post explaining what it is, so here we go:

From the upstream homepage:

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.

Actually, it is a library which does all that stuff and can be manipulated using its public API. But what does this actually means? I will explain it using augtool and /etc/hosts as an example. As you might know it has the information of the host names and their IP addresses, so let’s take this hosts as an example:

127.0.0.1 localhost localhost.localdomain host.domain

After parsing it on augeas we will end with:

/files/etc/hosts/
- – - – - – - – - – - 1/
- – - – - – - – - – - – ipaddr = 127.0.0.1
- – - – - – - – - – - – canonical = localhost
- – - – - – - – - – - – alias = localhost.localdomain
- – - – - – - – - – - – alias = host.domain

So, then we might want to change some values:

augtool> set /files/etc/hosts/1/alias[2] myhost.domain

Ending with:

/files/etc/hosts/
- – - – - – - – - – - 1/
- – - – - – - – - – - – ipaddr = 127.0.0.1
- – - – - – - – - – - – canonical = localhost
- – - – - – - – - – - – alias = localhost.localdomain
- – - – - – - – - – - – alias = myhost.domain

or add new values:

augtool> ins alias after /files/etc/hosts/1/alias[1]

what will turn into:

/files/etc/hosts/
- – - – - – - – - – - 1/
- – - – - – - – - – - – ipaddr = 127.0.0.1
- – - – - – - – - – - – canonical = localhost
- – - – - – - – - – - – alias = localhost.localdomain
- – - – - – - – - – - – alias
- – - – - – - – - – - – alias = myhost.domain

then we need to set a value since now it’s NULL:

augtool> set /files/etc/hosts/1/alias[2] myhost

ending like:

/files/etc/hosts/
- – - – - – - – - – - 1/
- – - – - – - – - – - – ipaddr = 127.0.0.1
- – - – - – - – - – - – canonical = localhost
- – - – - – - – - – - – alias = localhost.localdomain
- – - – - – - – - – - – alias = myhost
- – - – - – - – - – - – alias = myhost.domain

Then you can save it using:

augtool> save

Also you can add a new host, or whatever you want, just need to play with the tree.

Ok, but how this Black Magic work and how can i expand it to read new configuration files? Augeas uses lenses which are a Meta Data type using regular expressions that is being used for parsing, reading and writing configuration files. If you want to play around with lenses you can check this step-by-step tutorial written by Raphael Pinson (Thank you!)

nxvl @ July 18, 2008

7 Comments

  1. RoAkSoAx July 19, 2008 @ 1:08 am

    Finally I understand :D :D :P

  2. foo July 19, 2008 @ 4:13 am

    Sounds cool, how does it deal with comments?

    Does it share parsing code with the apps? Hmm, perhaps the projects parsing all the files could be convinced to export libraries for use by augeas!

  3. nxvl July 19, 2008 @ 11:25 am

    foo: Comments are defined in lenses also, they are not showed on the tree, but are stored for writing them back into the file on save.

    And yes, it is a library with a Public API, augtool is just an example tool so you can play with the library and see what is being done.

  4. Raphink July 20, 2008 @ 11:37 am

    Comments can actually also be taken as normal fields. This is what I do in my lenses usually, so that I can see them, and add or modify comments in the file.

    For example represent :
    “field1-1
    # comment 1
    field2-4
    # another comment

    with

    [...]/field1 = “1″
    [...]/comment[1] = “comment 1″
    [...]/field2 = “2″
    [...]/comment[2] = “another comment”

    Lately, I’ve also been busy trying to find a way to comment/uncomment in lenses (see the mailing list for details). In that case (which is still experimental), I would make a distinction between a comment and a commented value. So a file like :

    “field1=1
    # a random comment
    # field2=2

    Would be parsed as

    [...]/field1 = “1″
    [...]/comment = “a random comment”
    [...]/field2 = “2″
    [...]/field2/commented

    There is still discussion on the usability of such a parsing, whether it is considered useful that developers have to check for the existence of the “commented” flag before using the parsed value. I believe it could help to write nice interfaces that allow to comment/uncomment values.

    As for Augeas being used in applications, it is the goal, just like nxvl pointed out. Augeas is a C library with bindings for python, ruby, ocaml and perl. Dominique Dumont, the author of the Config::Model Perl module (cf. CPAN) is also porting Augeas a new engine for his module.

  5. Raphink July 20, 2008 @ 11:43 am

    For more info on comments management, see the mailing list :
    https://www.redhat.com/archives/augeas-devel/2008-July/msg00045.html

  6. unarturbarmat January 22, 2010 @ 10:31 am

    How is it going,

    Apparently this guy
    Is giving away accounts
    http://runescapegiveaway.com

    this is not my site

  7. chipshutcrammy February 2, 2010 @ 10:51 am

    Howdy

    With the increasing popularity of bebo poker chips as a virtual currency in facebook texas holdem poker a lot of phishers have engaged themselves, who try their best to trick unsuspecting players out of their hard earned myspace poker chips. All over the internet forums are littered with posts by innocent people who have had their chips stolen. Nothing is as sorry state as logging to Facebook or MySpace to play a few games of poker only to find that your account is hacked and your poker chips are gone.

    http://www.chipshut.com/img/facebook-poker-chips-hut.jpg

    Follow these tips to keep your facebook poker chips safe:

    Never give your password to a stranger: Trust is a delicate thing that takes a long time to build but only second to destroy. You may meet a sexy girl in poker room and you are friends with him/her. He/she will keep interacting with you days before playing her trick. So be carefull enough to protect your login credentials to yourself, else this may lead to disaster.

    Be careful about what you download: Serious online gamers are looking for cheats or hacks for the games they play in order to give them an advantage over their opponents. Poker is no different and there are plenty of websites on the internet having facebook poker cheats and hacks for those brave enough to download and install them. But many of these so called facebook poker cheats have viruses or trojan programs. The moment you install any of these your computer is at the risk of attacks by the creator of the program. He can then have access to vital information that you access from your computer. Leaving your facebook poker account at risk of been hacked. If you never downloaded any of these programs then you’re probably safe, and if you have then you should run a spyware detection program. The best move will be for get your computer formatted to avoid any loop holes.

    Phishing Links: This way of hacking has been thee for quite sometime now. Hackers send legitimate and official looking emails to your inbox. When you open them you are asked to click on the link and login in order to save your account or win free facebook poker chips, but in reality you are logging into a fake site that sends your information off to the hacker who made it. Before you find it out, its too late to react and they would have already broken into your account and emptied it of any facebook poker chips that you may have.

    YouTube scams: If you do a search on youtube for facebook poker cheats, zynga poker hacks, or free facebook poker chips you’ll find hundreds of videos on the topic. More than 90% of them are made by idiots hoping to convince you to send them your account information. They range from slightly clever to completely moronic.

    Image Photo Having Exe Embedded In it: This one is hard to catch. This is the latest fashion that is used by hacker, you will be asked to share family photo’s. When you open their photo, that will innitiate an exe in the background which will steal all your information and send to the mastermind behin it. So be careful with whom you share photos.

    Hope these tips help you saving your chips.

    These tips have been brought to you by Chips Hut if you are looking to buy facebook poker chips, you may go to our online store.

    Thankshttp://www.chipshut.com/img/chips-hut-smily.gif

Leave a comment


Feed