Ask Your Question

Using commas in augeas set commands

asked 2015-06-11 22:58:28 -0600

optize gravatar image

I'm using augeas to modify the options of /etc/fstab.


augeas { 'fstab-home':
       context => "/files/etc/fstab/*[file = '/home']",
       changes => [
                "set opt noatime,rw",

However, it fails everytime if there's multiple values for the set command. If I change it to noatime, it works fine. Is there a way to allow for multiple variables in the set command?

edit retag flag offensive close merge delete


what value you get when you do "print /files/etc/fstab" in augtool

Chutki gravatar imageChutki ( 2015-06-12 01:48:52 -0600 )edit

Here is the one for /home /files/etc/fstab/3
/files/etc/fstab/3/spec = "UUID=<<uuid>>"
/files/etc/fstab/3/file = "/home"
/files/etc/fstab/3/vfstype = "ext4"
/files/etc/fstab/3/opt = "defaults"
/files/etc/fstab/3/dump = "1"
/files/etc/fstab/3/passno = "2"

optize gravatar imageoptize ( 2015-06-12 05:03:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-12 10:08:06 -0600

GregLarkin gravatar image

updated 2015-06-12 13:03:39 -0600

Options in the /etc/fstab file are stored as an array in augeas, one entry for each option. Have a look at this output from augtool:

Sample line from /etc/fstab:

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

Output of "print /files/etc/fstab" from augtool for that line in the file:

/files/etc/fstab/5/spec = "devpts"
/files/etc/fstab/5/file = "/dev/pts"
/files/etc/fstab/5/vfstype = "devpts"
/files/etc/fstab/5/opt[1] = "gid"
/files/etc/fstab/5/opt[1]/value = "5"
/files/etc/fstab/5/opt[2] = "mode"
/files/etc/fstab/5/opt[2]/value = "620"
/files/etc/fstab/5/dump = "0"
/files/etc/fstab/5/passno = "0"

You will have to construct your augeas commands to replicate the "opt[1]" and "opt[2]" form shown above to achieve your goal.

UPDATE: In many cases, the herculesteam augeas provider modules on the Puppet Forge make working with augeas much, much easier. I would suggest having a look at this module in particular and writing you code to target it instead of a plain augeas resource. Your code will also look cleaner!

edit flag offensive delete link more


Thanks for the post - I did see several examples like that, however it errors out on [#] format. Here is an example: changes => [ "set opt[1] gid", "set opt[1]/value 5", "set opt[2] rw", ],

optize gravatar imageoptize ( 2015-06-12 11:07:35 -0600 )edit

It works with opt[1] but as soon as I add opt[2] it fails.

optize gravatar imageoptize ( 2015-06-12 11:08:06 -0600 )edit

Please post a link to the output of your agent run with debugging turned on so we can see the actual error.

GregLarkin gravatar imageGregLarkin ( 2015-06-12 11:58:54 -0600 )edit

optize gravatar imageoptize ( 2015-06-12 12:29:41 -0600 )edit

I can't tell what the problem is there - looks like it should work. Please see my updated answer for an alternate solution.

GregLarkin gravatar imageGregLarkin ( 2015-06-12 13:02:13 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-06-11 22:58:28 -0600

Seen: 935 times

Last updated: Jun 12 '15