-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmac-cleanup.yml
More file actions
63 lines (52 loc) · 1.62 KB
/
Copy pathmac-cleanup.yml
File metadata and controls
63 lines (52 loc) · 1.62 KB
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
---
# Mac Cleanup Example
#
# Author: Assaf Feuerstein
#
# Quick example to clean up disk space on Mac build machines.
#
# Usage:
# ansible-playbook mac-cleanup.yml -i hosts.ini
# ansible-playbook mac-cleanup.yml -i hosts.ini -l build-mac-01
- name: Mac Cleanup
hosts: all
remote_user: "{{ ansible_user | default('admin') }}"
gather_facts: no
become: yes
vars:
build_user: "{{ build_user | default('buildagent') }}"
tasks:
- name: Get disk usage before cleanup
shell: df -h / | tail -1 | awk '{print $4}'
register: disk_before
changed_when: false
- name: Clean Homebrew cache
shell: brew cleanup -s
become_user: "{{ build_user }}"
ignore_errors: true
- name: Clean npm cache
shell: npm cache clean --force
become_user: "{{ build_user }}"
ignore_errors: true
- name: Clean CocoaPods cache
shell: pod cache clean --all
become_user: "{{ build_user }}"
ignore_errors: true
- name: Clean Xcode derived data
file:
path: "/Users/{{ build_user }}/Library/Developer/Xcode/DerivedData"
state: absent
ignore_errors: true
- name: Clean temporary files
shell: rm -rf /tmp/Unity* /tmp/flutter* /tmp/dotnet* 2>/dev/null || true
changed_when: false
- name: Get disk usage after cleanup
shell: df -h / | tail -1 | awk '{print $4}'
register: disk_after
changed_when: false
- name: Display results
debug:
msg: |
Cleanup complete on {{ inventory_hostname }}
Disk free before: {{ disk_before.stdout }}
Disk free after: {{ disk_after.stdout }}