Skip to content

Commit

Permalink
Merge pull request #78 from adfinis/fix_10-037
Browse files Browse the repository at this point in the history
fix: logrotate parsing to actually remove managed logs from being flagged
  • Loading branch information
SaschaD-Adfinis authored Jan 8, 2025
2 parents c531242 + 04f8da8 commit f9e7ee7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit f9e7ee7

Please sign in to comment.