[augeas-devel] logrotate lense - multiple files

haerry+augeas at puzzle.ch haerry+augeas at puzzle.ch
Tue Jun 2 01:11:54 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

>> (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)

ok just realised that I have been on 0.24.7+variouspatches upgrading to
0.24.8 fixed puppet from reapplying the changes on every run. So I
remembered correctly that there have been a bug report for it for puppet.

However would the onlyif avoid unnecessary augeas calls?

> 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

cool, this works fine:

augeas { "logrotate":
    changes => [ 'rm /files/etc/logrotate.d/httpd/rule/file',
		 'ins file before /files/etc/logrotate.d/httpd/rule/*[1]',
		 'ins file before /files/etc/logrotate.d/httpd/rule/*[1]',
		 'set /files/etc/logrotate.d/httpd/rule/file[1] /var/log/httpd/*log',
		 'set /files/etc/logrotate.d/httpd/rule/file[2]
/var/www/vhosts/*/logs/*log' ],
}


thanks a lot!

It looks a bit ugly to do all that, but if understood it correctly the
following reasons are responsible for it:

The normal file is just a single value, however to add an additional
file to the logrotate, we need to transform this to a list. So we first
remove the list, then create it and afterwards fill it up?

cheers Marcel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkokfFgACgkQxqnHThA4pElkFACgwsonq4o7SaffMyNQg3pQkoao
JfAAoMH0tWuLkBYOa66adux+bOl072xJ
=cy8G
-----END PGP SIGNATURE-----




More information about the augeas-devel mailing list