Working alertmanager source. Starting playbook to clean logfiles
This commit is contained in:
23
playbooks/clean_logs.yml
Normal file
23
playbooks/clean_logs.yml
Normal 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) }}"
|
||||
Reference in New Issue
Block a user