-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-packages-and-free-space.yml
63 lines (52 loc) · 1.43 KB
/
update-packages-and-free-space.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: Install packages, reboot and clean cache
become: true
hosts: buildbots
tasks:
- name: Update all packages
package:
name: '*'
state: latest
- name: check if reboot is needed
command: "dnf needs-restarting -r -s"
register: needs_restarting
changed_when: needs_restarting.rc == 1
failed_when: false
notify: Reboot after update
- name: Clean the dnf cache
command: dnf clean all
handlers:
- name: Reboot after update
reboot:
- name: Clean the systemd logs
gather_facts: no
hosts: buildbots
tasks:
- name: clean logs older than 30 days
command: journalctl --vacuum-time=30d
changed_when: False
- name: Clean disk space
gather_facts: no
hosts: buildbots
become: true
tasks:
- name: Stop the buildbot worker service
service:
name: buildbot-worker.service
state: stopped
- name: Find the folders to remove and register them to a var
find:
paths: "/home/buildbot/buildarea/"
file_type: any
patterns: '3.*,pull_request*,custom*,twistd.log.*'
register: cleanup
- name: Remove the files
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ cleanup.files }}"
loop_control:
label: "{{ item.path }}"
- name: Start again the buildbot worker service
service:
name: buildbot-worker.service
state: started