[augeas-devel] Use of Record Sequences

David Lutterkort dlutter at redhat.com
Tue Feb 26 19:11:01 UTC 2008


On Tue, 2008-02-26 at 13:23 -0500, Bryan Kearney wrote:
> I have not read through Bison and Flex yet, so this discussion may be 
> from ignorance. Is it possible to use one of the record labels as the 
> unique key?

Yes, you can. That's what the key lens does, an example of that is in
yum.aug. 'key RE' for some regular expression RE matches that regular
expression against the file during parsing and uses it as the label of
the enclosing tree (marked with '[' .. ']')

> For example, the ipaddress or canonical for the host file or the type 
> for the pam file.

While you could use ipaddress in the hosts file for that, there's no
guarantee that the type in a pam file is unique, look for example
at /etc/pam.d/system-auth

That situation is the main reason for having synthetic keys generated by
'seq'

> Trying to think through the use of it, I would want to 
> be able to set / remove based on a logical id.. not exact placement in 
> the file.

Since many config files don't have natural primary keys for their
entries, Augeas lets you generate synthetic keys with 'seq NAME' and
then find entries with match. For example, to find the entry for
initdefault in /etc/inittab, you'd do

        match /system/config/inittab/*/action initdefault
        
(the rec-initdefault.rb test in tests/ uses that to change the default
runlevel)

> For .. example:
> 
> Add an ipaddress for augeas.net.
> 
> set /system/config/hosts/augeas.net/ipaddress 192.222.333.111
> 
> or remove the record completlu:
> 
> clear /system/config/hosts/augeas.net

To remove, you need to use 'rm' ... 'clear' only sets the value
associated with a path to NULL (it's really just a special case of
'set'), it doesn't delete anything.

David







More information about the augeas-devel mailing list