I'm trying to edit /etc/fstab.  I'm trying to change the following line:

tmpfs                   /dev/shm                tmpfs   defaults        0 0


and add size=256m (and a few other options, but just testing with that for now).

I have this puppet bit:

    define opt ( $fname, $opt, $value ) {
        $key = $name
        $context = "/files/etc/fstab"

        augeas { "$key-$fname-$opt-$value":
            context => "$context",
            onlyif => "match *[spec='$key'][file='$fname']/opt[.='$opt'] size 
== 0",
            changes => [ "set *[spec='$key'][file='$fname']/opt[last()+1] $opt",
                         "set *[spec='$key'][file='$fname']/opt[last()]/value 
$value",
                       ],
        }
    }


Which basically does what I want to do in augtool:

augtool> print /files/etc/fstab/*[spec='tmpfs']/files/etc/fstab/12
/files/etc/fstab/12/spec = "tmpfs"
/files/etc/fstab/12/file = "/dev/shm"
/files/etc/fstab/12/vfstype = "tmpfs"
/files/etc/fstab/12/opt = "defaults"
/files/etc/fstab/12/dump = "0"
/files/etc/fstab/12/passno = "0"
augtool> set /files/etc/fstab/*[spec='tmpfs'][file='/dev/shm']/opt[last()+1] 
size
augtool> set /files/etc/fstab/*[spec='tmpfs'][file='/dev/shm']/opt[last()] 256m
augtool> print /files/etc/fstab/*[spec='tmpfs']/files/etc/fstab/12
/files/etc/fstab/12/spec = "tmpfs"
/files/etc/fstab/12/file = "/dev/shm"
/files/etc/fstab/12/vfstype = "tmpfs"
/files/etc/fstab/12/opt[1] = "defaults"
/files/etc/fstab/12/dump = "0"
/files/etc/fstab/12/passno = "0"
/files/etc/fstab/12/opt[2] = "256m"


However, there seems to be an error here:

augtool> save
error: Failed to execute command
error: saving failed (run 'print /augeas//error' for details)
augtool> print /augeas//error
/augeas/files/etc/fstab/error = "put_failed"
/augeas/files/etc/fstab/error/path = "/files/etc/fstab/12"
/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\" = \"tmpfs\" } { \"file\" = \"/dev/shm\" } { \"vfstype\" = 
\"tmpfs\" } { \"opt\" = \"defaults\" } { \"dump\" = \"0\" } { \"passno\" = 
\"0\" } { \"opt\" = \"256m\" }"


I'm guessing it is from this:

#fstab.aug
  let record = [ seq "mntent" .
                   [ label "spec" . store spec ] . sep_tab .
                   [ label "file" . store Rx.neg1 ] . sep_tab .
                   comma_sep_list "vfstype" . sep_tab .
                   comma_sep_list "opt" .
                   (sep_tab . [ label "dump" . store /[0-9]+/ ] .
                    ( sep_spc . [ label "passno" . store /[0-9]+/ ])? )?
                 . eol ]


where the "opt" comma_sep_list is only allowed in one place, but the augtool 
change (and the puppet augeas change) converts it to an array/list (from a 
single 
entry), but puts the second entry at the end instead of with the other 
entry.

Is this a defect in the lens, or in my code?  What would be the best way of 
fixing this problem.

I'd rather use augeas rather than the puppet mount type for flexibility.

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

Reply via email to