ansible-logrotate
ansible-logrotate copied to clipboard
support for multiple commands in a single script
This commit makes it possible to have multiple actions in a script, eg. like this:
"/var/log/php-application/*.log" { daily rotate 0 create ifempty su apache apache lastaction /usr/bin/find -type f -mtime +7 -delete /usr/bin/find -type f -mtime +1 -exec gzip -q {} ; endscript }
Please add a test for this demonstrating two different script types.
This should already work using multi-line YAML entries, e.g. like this:
logrotate_scripts:
- name: php-application
paths:
- "/var/log/php-application/*.log"
options:
- daily
- rotate 0
- create
- ifempty
- su apache apache
scripts:
lastaction: |
/usr/bin/find -type f -mtime +7 -delete
/usr/bin/find -type f -mtime +1 -exec gzip -q {} ;
The |
(pipe) symbol allows to have multiple lines joined by newline characters. This produces the desired results.