[augeas-devel] logrotate lense - multiple files

David Lutterkort lutter at redhat.com
Mon Jun 1 19:48:20 UTC 2009


Hi Marcel,

On Mon, 2009-06-01 at 21:11 +0200, haerry+augeas at puzzle.ch wrote:
> I tried the following:
> 
> augeas { "logrotate":
>     context => "/files/etc/logrotate.d/httpd/rule",
>     changes => 'set file "/var/log/httpd/*log /var/www/vhosts/*/logs/*log"',
>     onlyif => 'get file != "/var/log/httpd/*log
> /var/www/vhosts/*/logs/*log"'
> }
> 
> (side note: is the onlyif now implicit by the changes?)

The Puppet type won't automatically derive any onlyif conditions, but
Augeas won't touch a file of your tree changes don't change the contents
of the file (e.g., because you set a node to a value it already has)

> this fails as augeas fails to save the change. The same if I try it in
> augtool:
> 
> augtool> set /files/etc/logrotate.d/httpd/rule/file "/var/log/httpd/*log
> /var/www/vhosts/*/logs/*log"
> augtool> save
> Saving failed
> 
> however if I have only one filepath I can change to whatever I'd like
> and it works as assumed.
> 
> I looked a bit at the lense and thought that the problem might be (if I
> interpreted the lense correctly) that only one word is allowed for file.
> Am I right?

The lens splits multiple files into multiple file nodes, i.e. what you
need to create is a structure like this:

  /files/etc/logrotate.d/httpd/rule
                                 file/ = /var/log/httpd/*log
                                 file/ = /var/www/vhosts/*/logs/*log
                                 ...

In augtool, the following commands accomplish that:

        # Set R as a convenience
        defvar r /files/etc/logrotate.d/httpd/rule
        print $r
        
        ## Use this as the changes in your puppet type
        # Remove existing file entries
        rm $r/file
        # Create two new empty file nodes as the first children of R
        ins file before $r/*[1]
        ins file before $r/*[1]
        # Set them to some value
        set $r/file[1] f1
        set $r/file[2] f2
        
        print $r
        save
        print /augeas//error
        
David





More information about the augeas-devel mailing list