-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.yml
More file actions
286 lines (255 loc) · 9.53 KB
/
Copy pathsetup.yml
File metadata and controls
286 lines (255 loc) · 9.53 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
- name: Provision Workstation
hosts: localhost
connection: local
gather_facts: true
vars:
# Modern fact syntax
home: "{{ ansible_facts['env']['HOME'] }}"
oh_my_zsh: "{{ ansible_facts['env']['HOME'] }}/.oh-my-zsh"
dotfiles:
- { src: "nvim", dest: "{{ home }}/.config/nvim" }
- { src: "tmux/.tmux.conf", dest: "{{ home }}/.tmux.conf" }
- { src: "zsh/.zshrc", dest: "{{ home }}/.zshrc" }
- { src: "tmux/tmux-attach", dest: "{{ home }}/.local/bin/tmux-attach" }
- { src: "tmux/tmux-sessionizer", dest: "{{ home }}/.local/bin/tmux-sessionizer" }
- { src: "harper/dictionary.txt", dest: "{{ home }}/.config/harper-ls/dictionary.txt" }
- { src: "aerospace/.aerospace.toml", dest: "{{ home }}/.aerospace.toml", os: "Darwin" }
- { src: "iterm", dest: "{{ home }}/.config/iterm", os: "Darwin" }
- { src: "iterm/profile.json", dest: "{{ home }}/Library/Application Support/iTerm2/DynamicProfiles/profile.json", os: "Darwin" }
- { src: "swiftbar/Plugins", dest: "{{ home }}/Library/Application Support/SwiftBar/Plugins", os: "Darwin" }
tasks:
# ==========================================
# 1. OS-Specific Package Management
# ==========================================
- name: Ubuntu | Install gpg for apt key management
become: true
ansible.builtin.apt:
name: gpg
state: present
update_cache: yes
when: ansible_facts['os_family'] == "Debian"
- name: Ubuntu | Create apt keyrings directory
become: true
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
when: ansible_facts['os_family'] == "Debian"
- name: Ubuntu | Add eza GPG key
become: true
ansible.builtin.shell: |
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
args:
creates: /etc/apt/keyrings/gierens.gpg
when: ansible_facts['os_family'] == "Debian"
- name: Ubuntu | Add eza apt repository
become: true
ansible.builtin.copy:
content: "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main\n"
dest: /etc/apt/sources.list.d/gierens.list
mode: '0644'
when: ansible_facts['os_family'] == "Debian"
- name: Ubuntu | Set correct permissions on eza keyring files
become: true
ansible.builtin.file:
path: "{{ item }}"
mode: '0644'
loop:
- /etc/apt/keyrings/gierens.gpg
- /etc/apt/sources.list.d/gierens.list
when: ansible_facts['os_family'] == "Debian"
- name: Ubuntu | Install packages and build dependencies
become: true
ansible.builtin.apt:
name:
- build-essential
- bat
- curl
- eza
- fd-find
- file
- git
- tmux
- zsh
- ripgrep
- fzf
- neovim
- libssl-dev
- zlib1g-dev
- libbz2-dev
- libreadline-dev
- libsqlite3-dev
- wget
- llvm
- libncurses5-dev
- xz-utils
- tk-dev
- libxml2-dev
- libxmlsec1-dev
- libffi-dev
- liblzma-dev
- bison
- xclip
state: present
update_cache: yes
when: ansible_facts['os_family'] == "Debian"
- name: Ubuntu | Symlink fdfind to fd
ansible.builtin.file:
src: /usr/bin/fdfind
dest: "{{ home }}/.local/bin/fd"
state: link
when: ansible_facts['os_family'] == "Debian"
- name: Ubuntu | Install pyenv via installer
ansible.builtin.shell: curl https://pyenv.run | bash
args:
creates: "{{ home }}/.pyenv"
when: ansible_facts['os_family'] == "Debian"
- name: macOS | Install Homebrew packages
community.general.homebrew:
name:
- zsh
- ripgrep
- fd
- fzf
- neovim
- pyenv
- jenv
- eza
- bat
- tmux
- bison
- tree-sitter-cli
state: present
update_homebrew: yes
when: ansible_facts['os_family'] == "Darwin"
- name: macOS | Install GUI Applications (Casks)
community.general.homebrew_cask:
name:
- iterm2
state: present
accept_external_apps: yes
when: ansible_facts['os_family'] == "Darwin"
- name: macOS | Run fzf install script
ansible.builtin.command: "$(brew --prefix)/opt/fzf/install --all --no-bash --no-fish"
args:
creates: "{{ home }}/.fzf.zsh"
when: ansible_facts['os_family'] == "Darwin"
# ==========================================
# 2. Shell & Terminal Setup
# ==========================================
- name: Clone Oh-My-Zsh
ansible.builtin.git:
repo: 'https://github.com/ohmyzsh/ohmyzsh.git'
dest: "{{ oh_my_zsh }}"
depth: 1
- name: Clone Zsh Plugins
ansible.builtin.git:
repo: "{{ item.url }}"
dest: "{{ oh_my_zsh }}/custom/plugins/{{ item.name }}"
loop:
- { name: 'pyenv-lazy', url: 'https://github.com/davidparsson/zsh-pyenv-lazy.git' }
- { name: 'zsh-nvm', url: 'https://github.com/lukechilds/zsh-nvm.git' }
- name: Clone Powerlevel10k Theme
ansible.builtin.git:
repo: 'https://github.com/romkatv/powerlevel10k.git'
dest: "{{ oh_my_zsh }}/custom/themes/powerlevel10k"
depth: 1
- name: Clone TPM (Tmux Plugin Manager)
ansible.builtin.git:
repo: 'https://github.com/tmux-plugins/tpm'
dest: "{{ home }}/.tmux/plugins/tpm"
depth: 1
# ==========================================
# 3. Fonts Setup
# ==========================================
- name: Set Font Directory Path
ansible.builtin.set_fact:
font_dir: "{{ (ansible_facts['os_family'] == 'Darwin') | ternary(home + '/Library/Fonts', home + '/.local/share/fonts') }}"
- name: Ensure Font Directory Exists
ansible.builtin.file:
path: "{{ font_dir }}"
state: directory
mode: '0755'
- name: Download MesloLGS NF Font
ansible.builtin.get_url:
url: 'https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf'
dest: "{{ font_dir }}/MesloLGS NF Regular.ttf"
register: font_download
- name: Linux | Refresh font cache
ansible.builtin.command: fc-cache -f -v
when: ansible_facts['os_family'] == "Debian" and font_download.changed
# ==========================================
# 4. Developer Tools
# ==========================================
- name: Install NVM
ansible.builtin.shell: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
args:
creates: "{{ home }}/.nvm/nvm.sh"
- name: Install Node.js via NVM
ansible.builtin.shell: |
. "{{ home }}/.nvm/nvm.sh"
nvm install node
nvm alias default node
args:
executable: /bin/bash
- name: Linux | Clone Jenv
ansible.builtin.git:
repo: 'https://github.com/jenv/jenv.git'
dest: "{{ home }}/.jenv"
when: ansible_facts['os_family'] == "Debian"
- name: Install GVM (Go Version Manager)
ansible.builtin.shell: bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
args:
creates: "{{ home }}/.gvm/scripts/gvm"
executable: /bin/bash
- name: Install Go (via GVM) and set as default
ansible.builtin.shell: |
source "{{ home }}/.gvm/scripts/gvm"
gvm install go1.26.3 -B
gvm use go1.26.3 --default
args:
creates: "{{ home }}/.gvm/gos/go1.26.3/bin/go"
executable: /bin/bash
- name: Install Rust via rustup
ansible.builtin.shell: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
args:
creates: "{{ home }}/.cargo/bin/rustc"
- name: Install Poetry (Python Package Manager)
ansible.builtin.shell: curl -sSL https://install.python-poetry.org | python3 -
args:
creates: "{{ home }}/.local/bin/poetry"
# ==========================================
# 5. Dotfiles Linking
# ==========================================
- name: Ensure parent directories for dotfiles exist
ansible.builtin.file:
path: "{{ item.dest | dirname }}"
state: directory
mode: '0755'
loop: "{{ dotfiles }}"
when: item.os is undefined or item.os == ansible_facts['os_family']
- name: Remove existing directories that would block symlinking
ansible.builtin.shell: |
if [ -d "{{ item.dest }}" ] && [ ! -L "{{ item.dest }}" ]; then
rm -rf "{{ item.dest }}"
fi
loop: "{{ dotfiles }}"
when: item.os is undefined or item.os == ansible_facts['os_family']
changed_when: false
- name: Symlink dotfiles
ansible.builtin.file:
src: "{{ playbook_dir }}/{{ item.src }}"
dest: "{{ item.dest }}"
state: link
force: yes
loop: "{{ dotfiles }}"
when: item.os is undefined or item.os == ansible_facts['os_family']
# ==========================================
# 6. Post-Install Hooks
# ==========================================
- name: Install tmux plugins headlessly
ansible.builtin.command: "{{ home }}/.tmux/plugins/tpm/bin/install_plugins"
environment:
TMUX_PLUGIN_MANAGER_PATH: "{{ home }}/.tmux/plugins/"
args:
creates: "{{ home }}/.tmux/plugins/tmux"