-
Notifications
You must be signed in to change notification settings - Fork 1
/
osx.yml
94 lines (88 loc) · 2.63 KB
/
osx.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
- name: OSX Stuff
hosts: osx
vars:
brewurl: https://raw.githubusercontent.com/Homebrew/install/{{commit}}/install
commit: d97fb9edbe2ea308400a894f7d1df7967717a937
script: ~/.homebrew.install.rb
sha256sum: 1a48258db024391a7864c155c9b6076744c18d39cd7403b04545881bda01f4a8
tasks:
- name: Workaround stupid path_helper
copy:
content: |
eval "$(/usr/libexec/path_helper -s)" 2>/dev/null
dest: ~/.bashrc
mode: 0750
- name: Homebrew install script
get_url:
dest: '{{script}}'
url: '{{brewurl}}'
sha256sum: '{{sha256sum}}'
- name: Install homebrew
shell: |
if hash brew >/dev/null 2>/dev/null
then echo already
else ruby {{script}}
fi
register: install
changed_when: install.stdout_lines != ['already']
failed_when: install.rc != 0
- name: Fix umask for multiuser machine
lineinfile:
dest: '{{homedir}}/.zsh.local/.zshenv'
line: '(( UID )) && umask 007 || umask 002'
create: yes
mode: 0644
- name: Fix homebrew permissions
become: true
shell: |
set -e
group={{wheel_group}}
for dir in /usr/local /Library/Caches/Homebrew /opt/homebrew-cask
do
test -d $dir || continue
if find $dir -maxdepth 2 ! -group $group | grep -q .
then chgrp -v -R $group $dir
fi
if find $dir -maxdepth 2 -perm -u+w ! -perm -g+w | grep -q .
then
chmod -v -R g=u $dir
find $dir -perm -u+w ! -perm -g+w -exec chmod -v -h g=u '{}' ';'
fi
done
register: perms
changed_when: perms.stdout_lines != []
failed_when: perms.rc != 0
- name: Packages
homebrew:
name: '{{item}}'
state: present
with_items:
- exiftool
- imagemagick
- p7zip
- pstree
- rsync # system version was 2.6.9, ©2006
- tmux
- zsh
- name: Activate Remote Desktop
become: true
shell: |
set -e
if ps -a -x -o 'command=' |
awk -F/ '{print$NF}' |
grep -Fxq ARDAgent
then echo already ; exit 0
fi
{
echo $USER
stat -f %Su /usr/local/bin
} |
sort |
uniq |
paste -sd, - |
while read usernames
do /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-activate -configure -access -on -users $usernames -privs -all -restart -agent
done
register: activated
changed_when: activated.stdout_lines != ["already"]