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

add hourly logrotate_frequency #27

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ The default values for the variables are set in [`defaults/main.yml`](https://gi
---
# defaults file for logrotate

# How often to rotate logs, either daily, weekly or monthly.
# How often to rotate logs, either hourly, daily, weekly or monthly.
logrotate_frequency: weekly

# How many files to keep.
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# defaults file for logrotate

# How often to rotate logs, either daily, weekly or monthly.
# How often to rotate logs, either hourly, daily, weekly or monthly.
logrotate_frequency: weekly

# How many files to keep.
Expand Down
2 changes: 1 addition & 1 deletion meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ argument_specs:
options:
logrotate_frequency:
type: str
description: "How often to rotate logs, either daily, weekly or monthly."
description: "How often to rotate logs, either hourly, daily, weekly or monthly."
default: "weekly"
logrotate_keep:
type: int
Expand Down
4 changes: 2 additions & 2 deletions tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
that:
- logrotate_frequency is defined
- logrotate_frequency is string
- logrotate_frequency in [ "daily", "weekly", "monthly" ]
- logrotate_frequency in [ "hourly", "daily", "weekly", "monthly" ]
quiet: true

- name: assert | Test logrotate_keep
Expand Down Expand Up @@ -85,7 +85,7 @@
ansible.builtin.assert:
that:
- item.frequency is string
- item.frequency in [ "daily", "weekly", "monthly" ]
- item.frequency in [ "hourly", "daily", "weekly", "monthly" ]
quiet: true
loop: "{{ logrotate_entries }}"
loop_control:
Expand Down
18 changes: 18 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,21 @@
enabled: "{{ logrotate_service_enabled }}"
when:
- logrotate_service != ""

- name: Enable hourly logrotate
community.general.ini_file:
dest: "/etc/systemd/system/{{ logrotate_service }}.d/override.conf"
section: Timer
option: OnCalendar
value: "hourly"
when:
- logrotate_service != ""
- logrotate_frequency == "hourly"

- name: Disable hourly logrotate
ansible.builtin.file:
path: "/etc/systemd/system/{{ logrotate_service }}.d/override.conf"
state: absent
when:
- logrotate_service != ""
- logrotate_frequency != "hourly"