On Wed, Apr 24, 2013 at 2:56 PM, Graham Leggett <[email protected]> wrote:
> On 24 Apr 2013, at 4:20 AM, Ian Mortimer <[email protected]> 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 > -s calls save. You don't really need it here since you're calling save manually. > set /files/etc/fstab/1[file='/home/monica/minfrin']/spec > "/dev/vg001/home-monica-minfrin2" > This line doesn't really make sense: you're selecting the first entry, but only if its file value is "/home/monica/minfin". I guess you want: set /files/etc/fstab/*[file='/home/monica/minfrin']/spec "/dev/vg001/home-monica-minfrin2" which will update whichever entry matches the condition (not only if it's the first one). If you want only the first entry matching the condition, then use: set /files/etc/fstab/*[file='/home/monica/minfrin'][1]/spec "/dev/vg001/home-monica-minfrin2" > save > print /augeas//error > EOF > > What I expected was for the existing line to be updated, and the result > saved. What I get instead is this: > > + augtool -s > error: Failed to execute command > error: saving failed (run 'print /augeas//error' for details) > /augeas/files/etc/fstab/error = "put_failed" > /augeas/files/etc/fstab/error/path = "/files/etc/fstab/1" > /augeas/files/etc/fstab/error/lens = > "/usr/share/augeas/lenses/dist/fstab.aug:23.17-30.22:" > /augeas/files/etc/fstab/error/message = "Failed to match \n { /spec/ = > /[^\\001-\\004\\t\\n #,][^\\001-\\004\\t\\n ]*/ }{ /file/ = > /[^\\001-\\004\\t\\n #,]+/ }{ /vfstype/ = /[^\\001-\\004\\t\\n #,=]+/ }({ > /vfstype/ = /[^\\001-\\004\\t\\n #,=]+/ })*{ /opt/ = /[^\\001-\\004\\t\\n > #,=]+/ }({ /opt/ = /[^\\001-\\004\\t\\n #,=]+/ })*({ /dump/ = /[0-9]+/ }({ > /passno/ = /[0-9]+/ })?)?\n with tree\n { \"spec\" = > \"/dev/vg001/home-monica-minfrin2\" }" > > The entry didn't exist at all (or was not the first entry, as mentioned above), so your "set" command created a "spec" node in the tree, without the other mandatory sibling nodes for a valid fstab entry. When trying to save the new tree to the file, it failed because the tree was not valid. Regards, -- Raphaël Pinson Développeur et Formateur Infrastructure +33 479 926 57 93 Camptocamp France Savoie Technolac BP 352 48, avenue du Lac du Bourget 73372 Le Bourget du Lac, Cedex www.camptocamp.com
_______________________________________________ augeas-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/augeas-devel
