-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTemplate-Clean-Logs.yml
63 lines (61 loc) · 1.37 KB
/
Template-Clean-Logs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
- name: clean old logs
file: path={{ item }} state=absent
with_items:
- /var/log/auth.log
- /var/log/boot
- /var/log/boot.log
- /var/log/btmp
- /var/log/daemon.log
- /var/log/debug
- /var/log/dmesg
- /var/log/dpkg.log
- /var/log/faillog
- /var/log/kern.log
- /var/log/lastlog
- /var/log/lpr.log
- /var/log/mail.err
- /var/log/mail.info
- /var/log/mail.log
- /var/log/mail.warn
- /var/log/maillog
- /var/log/messages
- /var/log/pycentral.log
- /var/log/secure
- /var/log/syslog
- /var/log/udev
- /var/log/ufw.log
- /var/log/user.log
- /var/log/wtmp
- /var/log/yum.log
- /var/spool/mail/root
- /root/*
- /home/*
- /root/.history
- /root/.bash_history
- name: clean really old logs
shell: rm -Rf {{ item }}
with_items:
- /var/log/*old
- /var/log/*0
- /var/log/*.?
- /var/log/user.log.?
- /var/log/kern.log.?
- /var/log/auth.log.?
- /var/log/daemon.log.?
- /var/log/upstart/*
- /var/log/sa/*
- /var/log/dmesg*
- /var/log/*-201*
- /var/log/*gz
- /var/log/*bz?
ignore_errors: true
- name: recreate required logs
file: path={{ item }} state=touch
with_items:
- /var/log/messages
- /var/log/syslog
- /var/log/lastlog
- name: clean yum cache
when: ansible_os_family == "RedHat"
shell: yum clean all