Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running hourly logrotates #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
---

logrotate_conf_dir: "/etc/logrotate.d/"
logrotate_scripts: []
logrotate_support_hourly_rotates: true
14 changes: 14 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
---

- name: nickhammond.logrotate | Install logrotate
package:
name: logrotate
state: present
when: logrotate_scripts is defined and logrotate_scripts|length > 0

- name: Check for logrotate daily cron entry
stat:
path: "{{ logrotate_cron_daily_location }}"
register: daily_cron_entry
when: logrotate_support_hourly_rotates

- name: Move logrotate cron entry from daily to hourly
command: "mv '{{ logrotate_cron_daily_location }}' '{{ logrotate_cron_hourly_location }}'"
args:
creates: "{{ logrotate_cron_hourly_location }}"
removes: "{{ logrotate_cron_daily_location }}"
when: logrotate_support_hourly_rotates and daily_cron_entry.stat.exists

- name: nickhammond.logrotate | Setup logrotate.d scripts
template:
src: logrotate.d.j2
Expand Down
4 changes: 4 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---

logrotate_cron_hourly_location: /etc/cron.hourly/logrotate
logrotate_cron_daily_location: /etc/cron.daily/logrotate