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

fix: logrotate parsing to actually remove managed logs from being flagged #78

Open
wants to merge 3 commits into
base: main
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
7 changes: 4 additions & 3 deletions roles/maintenance_10_linux/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
taskid: 10-037
name: "Logrotate: Are there large files that point to a too verbose service?"
ansible.builtin.set_fact:
logrotate_logs: "{{ logrotate_output.content | b64decode | split('\n') }}"
logrotate_logs: "{{ logrotate_output.content | b64decode | split('\n') | map('split',' ') | map('first') |map('trim', '\"') | list }}"

- <<: *task
vars:
Expand All @@ -141,20 +141,21 @@
pattern: "*.log"
exclude: "{{ linux_allowed_large_files + linux_additional_allowed_large_files }}"
register: all_logs
changed_when: false

- <<: *task
vars:
taskid: 10-037
name: "Logrotate: Are there large files that point to a too verbose service?"
ansible.builtin.set_fact:
unmanaged_logs: "{{ all_logs.found | reject('in', (logrotate_output.content | b64decode)) | list }}"
unmanaged_logs: "{{ all_logs.found | reject('in', logrotate_logs) | list }}"

- <<: *task
vars:
taskid: 10-037
name: "Logrotate: Are there large files that point to a too verbose service?"
ansible.builtin.debug:
msg: "List of unrotated logs: {{ unmanaged_logs }}"
msg: "List of logs not managed by logrotate: \n{% for item in unmanaged_logs %}{{ item + '\n'}}{% endfor %}"
when:
- "vars.taskid not in maintenance_exclude_tasks"
- "maintenance_only is not defined or maintenance_only == vars.taskid"
Expand Down
1 change: 1 addition & 0 deletions roles/maintenance_10_linux/vars/RedHat7.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---

linux_logrotate_status_file: "/var/lib/logrotate/logrotate.status"
# linux_allowed_login_since: not supported in RHEL 7