[augeas-devel] "ins" statement in augtool can corrupt the edited file

Marc Fournier marc.fournier at camptocamp.com
Mon Sep 29 09:51:31 UTC 2008


Hello,

I noticed that when using the following statement in augtool, part of
the edited file gets lost (at least when using the inifile lens):

"ins item=value <WHERE> <PATH>"

I know this is not the way "ins" should be used, but it is tempting to
try to. Maybe augtool should catch this case and send an error to the
user instead ? Or perhaps "ins" could also work in this sort of
"2-in-1" mode ?

The following example illustrates the problem I came across:

----8<--------------------------------------------------

marc at lonquimay:~/src/augeas/lenses$ cat /tmp/puppet.conf
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
pluginsync=true

[puppetmasterd]
templatedir=/var/lib/puppet/templates

marc at lonquimay:~/src/augeas/lenses$ augtool -I .
augtool> ins foo after /files/tmp/puppet.conf/main/vardir
augtool> set /files/tmp/puppet.conf/main/foo bar
augtool> save
augtool> 
marc at lonquimay:~/src/augeas/lenses$ cat /tmp/puppet.conf
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
foo=bar
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
pluginsync=true

[puppetmasterd]
templatedir=/var/lib/puppet/templates

marc at lonquimay:~/src/augeas/lenses$ augtool -I .
augtool> ins bar=baz after /files/tmp/puppet.conf/main/vardir
augtool> save
augtool> 
marc at lonquimay:~/src/augeas/lenses$ cat /tmp/puppet.conf
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
[puppetmasterd]
templatedir=/var/lib/puppet/templates

----8<--------------------------------------------------


Thanks !

Marc





More information about the augeas-devel mailing list