Compare commits

..

No commits in common. "e22094ed62fe8849580dc4fec01b1ab6709d2c5a" and "2577db04be4425a5af49db5c5ab7ea0ef32cdbfe" have entirely different histories.

4 changed files with 0 additions and 72 deletions

BIN
ubuntu/.dns-flush.yaml.swp Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,72 +0,0 @@
- name: Clean Old Log Files and Cache
hosts: linux
become: true
serial: 1
vars:
log_dirs:
- /var/log
log_age_days: 30
tasks:
- name: Remove compressed/rotated log files older than {{ log_age_days }} days
ansible.builtin.find:
paths: "{{ log_dirs }}"
patterns: "*.gz,*.1,*.2,*.3,*.4,*.5,*.old"
age: "{{ log_age_days }}d"
recurse: true
register: old_logs
- name: Delete found old log files
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop: "{{ old_logs.files }}"
- name: Truncate large active log files (> 100MB) without deleting them
ansible.builtin.shell: |
find /var/log -type f -name "*.log" -size +100M | while read f; do
truncate -s 0 "$f"
done
changed_when: false
- name: Clean journal logs older than 30 days
ansible.builtin.command: journalctl --vacuum-time=30d
changed_when: false
- name: Limit journal size to 500MB
ansible.builtin.command: journalctl --vacuum-size=500M
changed_when: false
- name: Remove unused packages and dependencies
ansible.builtin.apt:
autoremove: yes
- name: Clean APT package cache
ansible.builtin.apt:
clean: yes
- name: Remove obsolete package files from APT cache
ansible.builtin.apt:
autoclean: yes
- name: Clean user thumbnail/cache directories
ansible.builtin.shell: |
find /home -maxdepth 3 -type d -name ".cache" | while read d; do
find "$d" -type f -atime +{{ log_age_days }} -delete 2>/dev/null || true
done
changed_when: false
- name: Clean /tmp files older than 7 days
ansible.builtin.find:
paths: /tmp
age: 7d
recurse: true
register: tmp_files
- name: Delete old /tmp files
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop: "{{ tmp_files.files }}"
ignore_errors: true

0
ubuntu/update.yaml Executable file → Normal file
View File