Hi list,

I have a problem with editing/appending to a line in a file where the lense 
describes nodes in the file as only numbers like /etc/hosts:

[r...@infrastructure-svn ~]# augtool
augtool> print /files/etc/hosts
/files/etc/hosts/1
/files/etc/hosts/1/ipaddr = "127.0.0.1"
/files/etc/hosts/1/canonical = "localhost.localdomain"
/files/etc/hosts/1/alias = "localhost"
...
/files/etc/hosts/4
/files/etc/hosts/4/ipaddr = "10.10.10.10"
/files/etc/hosts/4/canonical = "puppet"

What I am trying to do is use a 'set' command to either edit an existing line 
in the file (based on a pattern match on a 'module' node) or if one does not 
exist, create a new one. So basically it's an edit operation which appends if 
it doesn't exist. This can be done one other types of files where base node 
name is not just a number, /etc/exports for example is "keyed" on the node name 
'dir':

set dir[.='/home'] /home
set dir[.='/home']/client 10.10.10.10
set dir[.='/home']/client/option[1] ro

In this way the first 'set' command self-defines if it doesn't already exist, 
or it edits an existing line. I'd like to achieve the same thing in files where 
nodes are described like array indexes, but I can't figure out how. Here's a 
few examples I've tried:

augtool> set /files/etc/hosts/*/ipaddr[.='10.44.220.23'] 10.44.220.23
Failed
augtool> set /files/etc/hosts/*[ipaddr='10.44.220.23']/ipaddr 10.44.220.23
Failed

I'm using Augeas 0.7.3 on CentOS 5.5 and as you would have guessed, through 
Puppet. I suppose I can always do an 'rm <line>' then 'ins <new>' and use 
Puppet's onlyif clause to limit when the augeas statements will be run, but it 
would be nice if it was possible to do it with 'set' commands. I could edit 
portions of a line matching one of the line's nodes without affecting the rest 
of the line - this would be very useful for adding extra arguments to lines in 
/etc/pam.d files without affecting the rest of the line (especially the 
position). It may be Puppet's use of ruby-augeas that makes this impossible.

Exact software:

augeas-libs-0.7.3-1.el5
augeas-0.7.3-1.el5
ruby-augeas-0.3.0-1.el5

Any help is greatly appreciated,

Thanks

-Luke

Luke Bigum
Systems Engineer
Fasthosts Internet Ltd.
01452 541285
www.fasthosts.co.uk<http://www.fasthosts.co.uk/>

[cid:[email protected]]<http://www.fasthosts.co.uk/>

Company registration no. 3656438. Registered in England and Wales.

Registered office: Discovery House, 154 Southgate Street, Gloucester, GL1 2EX.

VAT no. 720821857.

<<inline: image001.gif>>

_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to