]> git.somenet.org - root/pub/somesible.git/blob - roles/cleanup/tasks/main.yml
roles/server/nginx/server
[root/pub/somesible.git] / roles / cleanup / tasks / main.yml
1 #####################################
2 ### someone's ansible provisioner ###
3 #####################################
4 # Part of: https://git.somenet.org/root/pub/somesible.git
5 # 2017-2026 by someone <someone@somenet.org>
6 #
7 # cleanup stuff.
8 # The aggressive mode should be followed by or part of a full somesible run.
9 #
10 ---
11 - name: cleanup /var/ansible/.ansible
12   file:
13     path: "/var/ansible/.ansible"
14     state: absent
15   changed_when: False
16
17
18 - name: cleanup apt download cache (TEMP)
19   include_tasks: run-command.yml
20   vars:
21     cmd: 'apt-get clean'
22   when: 'cleanup_level|int >= 2'
23
24
25 - name: cleanup old lock files (day)
26   include_tasks: run-command.yml
27   vars:
28     cmd: 'find /var/lib/letsencrypt/lock -type f -mmin +86400 -print -delete'
29   when: 'cleanup_level|int >= 3'
30
31
32 - name: cleanup old logfiles (543210 min = 377.23 days)
33   include_tasks: run-command.yml
34   vars:
35     cmd: 'find /var/log/ -type f -mmin +543210 -print -delete'
36   when: 'cleanup_level|int >= 3'
37
38
39 - name: cleanup old dist-files
40   include_tasks: run-command.yml
41   vars:
42     cmd: 'find /etc \( -name "*.dpkg-*" -o -name "*.ucf-*" -o -name "*.merge-error" \) -print -delete'
43   when: 'cleanup_level|int >= 4'
44
45
46 - name: cleanup old munin files (543210 min = 377.23 days)
47   include_tasks: run-command.yml
48   vars:
49     cmd: 'find /var/lib/munin*/* -type f -mmin +543210 -print -delete'
50   when: 'cleanup_level|int >= 5'
51
52
53 - name: cleanup old anope db files (543210 min = 377.23 days)
54   include_tasks: run-command.yml
55   vars:
56     cmd: 'find /srv/anope/db/backups -type f -mmin +543210 -print -delete'
57   when: 'cleanup_level|int >= 5'
58
59
60 ###################################################
61 # cleanup possibly stale configs generated by us. #
62 ###################################################
63 - name: remove systemd presets
64   include_tasks: run-command.yml
65   vars:
66     cmd: 'rm -vf /etc/systemd/system-preset/*-somesible-*'
67   when: 'cleanup_level|int >= 6'
68
69
70 # level 7 can cause issues by skipping over stuff if run at the wrong time.
71
72 - name: remove all awstat configs
73   include_tasks: run-command.yml
74   vars:
75     cmd: 'rm -vf /etc/awstats/awstats.*.conf'
76   when: 'cleanup_level|int >= 7'
77
78
79 # level 9 is expected to cause downtimes + the need to run multiple times/manually start (now/temp.) broken services.
80
81 - name: remove all vhost configs
82   include_tasks: run-command.yml
83   vars:
84     cmd: 'rm -vf /etc/nginx/sites-enabled/*.vhost'
85   when: 'cleanup_level|int >= 9'