I am currently writing a puppet module for adding lines to auto.misc file.

I used augeas for adding a new entry to the auto.misc file and I came up with like something below and it works quite well every time I run without duplicating.

augeas { "new auto mountpoint":

        context => "/files/etc/auto.misc",
        changes => [

            "set 01 'store'",
            "set 01/opt[1] 'ro'",
            "set 01/opt[2] 'soft'",
            "set 01/opt[3] 'intr'",
            "set 01/location/1/host 'uxkickstart.thenational.com'",
            "set 01/location/1/path '/common'",
        ],

        onlyif  => "match *[. = 'store'] size == 0",
    }

Now if i want to add a new option for a particular mount-point , it never gets updated.

If someone could tell me whats the best way to do this or use augeas in a different way to fix the issue here, it would be great.

Thanks

2

There are 2 answers

0
raphink On

The best option here is to write a proper type+augeas provider instead of using the augeas type. This will let you specify the options as an array property.

See augeasproviders.com for examples, and various modules implementing augeas providers on github.

2
Chris Pitman On

If you only need to add/modify a line at a time, then the file_line resource from puppetlabs-stdlib is way easier to use than augeas.