[augeas-devel] Calling augtool from a script

Dominic Cleal dcleal at redhat.com
Wed Apr 24 13:51:51 UTC 2013


On 24/04/13 13:56, Graham Leggett wrote:
> On 24 Apr 2013, at 4:20 AM, Ian Mortimer <i.mortimer at uq.edu.au> wrote:
> 
>> Here's a very simple example from a centos kickstart %post:
>>
>> augtool -s <<-EOF
>> set /files/etc/pam.d/system-auth-ac/*[module = 'pam_mkhomedir.so']/argument[1] umask=0077
>> set /files/etc/pam.d/password-auth-ac/*[module = 'pam_mkhomedir.so']/argument[1] umask=0077
>> rm /files/etc/ntp.conf/server[. =~ regexp('.*\.centos\.pool\.ntp\.org')]
>> EOF
> 
> Extending the above, I tried the following:
> 
> augtool -s <<-EOF
> set /files/etc/fstab/1[file='/home/monica/minfrin']/spec "/dev/vg001/home-monica-minfrin2"

This should be /files/etc/fstab/*[file= .... and not "1".  See the
example in my last e-mail.

What's happening is you're specifying that you want to change a node
that is:

1. the first entry in the file (the "1")
2. *and* has the path /home/manica/minfrin

I'm guessing your entry probably isn't the first in fstab, so it doesn't
match.  This causes a new node to be created, which now only has the
"spec" given.  When you save it's not a full entry (with every field in
the fstab) so it's causing the error.

Use "print" as suggested in my e-mail to have a look at the tree as you
modify it.  It's really the best way to learn and see what's going on
without stabbing away in the dark.  You would see by running "print
/fiels/etc/fstab" after running your set command that you haven't in
fact changed the "spec" of your entry.

-- 
Dominic Cleal
Red Hat Engineering




More information about the augeas-devel mailing list