PuppetOn my web server, I keep my web sites in /var/lib/www. Each web site has a dedicated logs directory. Since logrotate is already rotating Apache logs on the server, I'd like to continue using that to rotate these log files as well. Below, is a Puppet snippet that uses Augeas to modify the stock Debian logrotate configuration file for Apache to include my custom log directories.

augeas { "apache2/logging/sites":
    lens    => "Logrotate.lns",
    incl    => "/etc/logrotate.d/apache2",
    changes => [
        "ins file after rule[file='/var/log/apache2/*.log']/file[last()]",
        "set rule[file='/var/log/apache2/*.log']/file[last()] '/var/lib/www/*/logs/*_log'",
    onlyif  => "match rule[file='/var/log/apache2/*.log']/file[.='/var/lib/www/*/logs/*_log'] size == 0",
    require => Noop["apache/installed"],
    before  => Noop["apache/configured"],