TLDR
Logrotate can really come in handy when you need to manage logfiles on your Linux machine. And this tutorial shows you how to set up logrotate via Ansible.
Example - Managing Rails Logfile with Logrotate
Details
- Triggers hourly
- Rotate when log file is bigger than 100M
- Only keep 10 copies
Configuring Ansible for Logrotate
-
roles/logrotate/tasks/main.yml
-
roles/logrotate/templates/rails.j2
Modify
/path/to/your/rails/log/{{ each_group.rails.env }}.log
to your logfile's path on your machine.
Provisioning Logrotate with Ansible
Refer to Executing playbooks.
Bonus
Checking whether Logrotate can be Called by Cron
Getting File/Directory Permission Numerical Value in Linux
I usually use sites like Chmod Calculator to map values.