forked from hichon78/macos-setup
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathosx.yml
More file actions
258 lines (235 loc) · 10.7 KB
/
Copy pathosx.yml
File metadata and controls
258 lines (235 loc) · 10.7 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
################################################################################
# BACKUP CUSTOM FILES
################################################################################
---
- name: "MAC OS Installation"
hosts: localhost
become: false
gather_facts: false
vars:
home: "/Users/{{ lookup('env', 'USER') }}"
tasks:
#---------------------------------------------------------------------------
- name: Read in Package Variables
include_vars:
dir: "./vars"
depth: 1
extensions:
- 'yml'
- 'yaml'
ignore_unknown_extensions: true
#failed_when: false
tags: always
############################################################################
# Homebrew
############################################################################
#===========================================================================
- name: 'add custom homebrew repos'
community.general.homebrew_tap:
name: "{{homebrew.taps}}"
tags:
- homebrew
#===========================================================================
- name: Install core packages via brew casks
community.general.homebrew_cask:
name: "{{ _cask }}"
failed_when:
- not 'Cask installed' in _cask_install_result.msg
- not 'Cask already installed' in _cask_install_result.msg
# Indicates it was installed via another channel
- not 'It seems there is already' in _cask_install_result.msg
register: _cask_install_result
loop: "{{homebrew.casks}}"
loop_control:
label: "Install homebrew cask - {{_cask}}"
loop_var: "_cask"
tags:
- homebrew
- name: "Install homebrew packages"
community.general.homebrew:
name: "{{_package}}"
state: present
update_homebrew: yes
register: _package_install_result
failed_when:
- not 'Package installed' in _package_install_result.msg
- not 'Package already installed' in _package_install_result.msg
loop: "{{homebrew.packages}}"
loop_control:
label: "Install homebrew package - {{_package}}"
loop_var: "_package"
tags:
- homebrew
############################################################################
# vim
############################################################################
- name: "Create vim rc file"
template:
src: templates/.vimrc
dest: "{{home}}/.vimrc"
owner: "{{ lookup('env', 'USER') }}"
force: true
tags:
- vim
- name: "Add vim-plug"
command:
cmd: "curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
tags:
- vim
############################################################################
# zshrc
############################################################################
- name: "Copy custom zshrc files"
template:
src: templates/{{_zshrc_file}}
dest: "{{home}}/{{_zshrc_file}}"
owner: "{{ lookup('env', 'USER') }}"
force: true
remote_src: false
loop:
- .zshrc
- .zshrc.custom.before
- .zshrc.custom.after
loop_control:
label: Copying over ... {{_zshrc_file}}
loop_var: _zshrc_file
tags:
- zshrc
- zsh
############################################################################
# zshrc
############################################################################
- name: "Copy SSH Keys and Config"
copy:
src: files/ssh/{{_ssh_file.name}}
dest: "{{home}}/.ssh/{{_ssh_file.name}}"
owner: "{{ lookup('env', 'USER') }}"
force: true
mode: "{{_ssh_file.mode}}"
loop: "{{ssh_config_files}}"
loop_control:
label: Copying over ... {{_ssh_file.name}}
loop_var: _ssh_file
tags:
- never # Only run when ssh is explicitly set
- ssh
############################################################################
# Oh My ZSH
############################################################################
- name: Install Oh My ZSH
command:
cmd: "sudo /bin/sh -c '$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)'"
args:
creates: "{{home}}/.oh-my-zsh"
tags:
- zsh
- name: Set ZSH as the default shell
shell: "sudo /usr/bin/chsh -s $(which zsh) {{ lookup('env', 'USER') }}"
tags:
- zsh
- name: Install Oh-My-ZSH plugins
command:
cmd: "git clone {{_zsh_plugin}}"
chdir: "$ZSH/plugins"
register: _zsh_plugin_result
failed_when:
- _zsh_plugin_result.rc > 0
- not 'already exists' in _zsh_plugin_result.stderr
loop: "{{zsh.plugins}}"
loop_control:
label: "Install oh-my-zsh theme - {{_zsh_plugin}}"
loop_var: "_zsh_plugin"
tags:
- zsh
- name: Install Oh-My-ZSH themes
command:
cmd: "git clone {{_zsh_theme}}"
chdir: "$ZSH/themes"
failed_when:
- _zsh_theme_result.rc > 0
- not 'already exists' in _zsh_theme_result.stderr
register: _zsh_theme_result
loop: "{{zsh.themes}}"
loop_control:
label: "Install oh-my-zsh theme - {{_zsh_theme}}"
loop_var: "_zsh_theme"
tags:
- zsh
- name: "Create a ZSH configuration"
template:
src: templates/{{_zsh_file}}
dest: "{{home}}/{{_zsh_file}}"
owner: "{{ lookup('env', 'USER') }}"
force: yes
loop:
- .zshrc
- .zshrc.custom.before
- .zshrc.custom.after
loop_control:
loop_var: "_zsh_file"
label: "Installing zsh config {{_zsh_file}}"
tags:
- zsh
- zshconf
############################################################################
# VSCode
############################################################################
- name: "Install from Mac app store"
command:
cmd: "mas install {{ _app.id }}"
loop: "{{app_store}}"
loop_control:
loop_var: "_app"
label: "Installing apple store app... {{_app.name}}"
tags:
- apps
############################################################################
# ASDF
############################################################################
- name: "Create a default asdf configuration"
template:
src: templates/.asdfrc
dest: "{{home}}/.asdfrc"
owner: "{{ lookup('env', 'USER') }}"
force: true
tags:
- asdf
- name: "Install asdf plugins"
command:
cmd: "asdf plugin-add {{ _asdf_plugin }}"
loop: "{{asdf.plugins}}"
loop_control:
label: "Install asdf plugin - {{_asdf_plugin}}"
loop_var: "_asdf_plugin"
tags:
- asdf
############################################################################
# VSCode
############################################################################
- name: Create a default VSCode configuration
template:
src: templates/vscode-settings.json
dest: "{{home}}/Library/Application Support/Code/User/settings.json"
owner: "{{ lookup('env', 'USER') }}"
force: yes
tags:
- vscode
# Bug - This fails on the first run becasue the directories don't exist yet
# you need to open vscode for the directories to be created. Do a validation of the directories.
- name: Create a default VSCode keuybinding configuration
template:
src: templates/vscode-keybindings.json
dest: "{{home}}/Library/Application Support/Code/User/keybindings.json"
owner: "{{ lookup('env', 'USER') }}"
force: yes
tags:
- vscode
- name: Install VSCode extensions
command:
cmd: "code --install-extension {{ _vscode_extension }}"
loop: "{{vscode.extensions}}"
loop_control:
label: "Install vscode extension - {{_vscode_extension}}"
loop_var: "_vscode_extension"
tags:
- vscode