Ask Your Question
0

Using commas in augeas set commands

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

optize gravatar image

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

Example:

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

Comments

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

Chutki gravatar imageChutki ( 2015-06-12 01:48:52 -0500 )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 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

GregLarkin gravatar image

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

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
/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! https://forge.puppetlabs.com/herculesteam/augeasproviders_mounttab

edit flag offensive delete link more

Comments

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 -0500 )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 -0500 )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 -0500 )edit

http://pastebin.ca/3025784

optize gravatar imageoptize ( 2015-06-12 12:29:41 -0500 )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 -0500 )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

Stats

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

Seen: 580 times

Last updated: Jun 12 '15