Working alertmanager source. Starting playbook to clean logfiles

This commit is contained in:
2024-01-18 07:59:42 -05:00
parent 7b5eac7ad1
commit 7056507aa9
2 changed files with 41 additions and 12 deletions

23
playbooks/clean_logs.yml Normal file
View File

@@ -0,0 +1,23 @@
---
- name: Clean log directory
hosts: all
tasks:
- name: Find files in directory ending in .log or .log.tgz larger than 1GB
ansible.builtin.find:
paths: /var/log
patterns: '*.log,*.log.tgz'
size: 1g
register: logfiles
# - name: Copy files to archive server
# ansible.builtin.copy:
# src: "{{ item.path }}"
# dest: "{{ archive_server_path }}/{{ item.path | basename }}"
# delegate_to: "{{ archive_server }}"
# loop: "{{ logfiles.files |flatten(levels=1) }}"
- name: Delete files
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop: "{{ logfiles.files | flatten(levels=1) }}"