-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcommon.yaml
504 lines (441 loc) · 18 KB
/
common.yaml
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
---
- name: Ensure common dependencies are installed
hosts: factory
tasks:
- name: When MacOSX ensure Homebrew packages are installed
block:
- name: Update homebrew and upgrade all packages
community.general.homebrew:
update_homebrew: yes
upgrade_all: yes
- name: Check if /usr/local/Cellar/bash-completion exists
ansible.builtin.stat:
path: /usr/local/Cellar/bash-completion
register: bash_completion
- name: Ensure bash-completion is not installed, so bash-completion@2 can be installed
ansible.builtin.shell: brew unlink bash-completion
when: bash_completion.stat.exists
- name: Ensure these HomeBrew packages are not installed
community.general.homebrew:
name:
- k3d
state: removed
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
- name: Ensure HomeBrew packages are installed
community.general.homebrew:
name:
- bash
- bash-completion@2
- zsh
- zsh-completion
- fish
- vim
- nano
- pwgen
- openssl
- watch
- gettext
- helm
- curl
- wget
- git-secrets
- tmux
- yamllint
- jq
- tree
- htop
- kubectl
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
- name: Get HOMEBREW_PREFIX
block:
- name: Execute brew --prefix
ansible.builtin.shell: brew --prefix
register: brew_prefix
- name: Create brew_fact with stdout of of prior command
ansible.builtin.set_fact:
HOMEBREW_PREFIX: "{{ brew_prefix.stdout }}"
when: ( ansible_distribution == 'MacOSX' )
- name: When Archlinux ensure pacman packages are installed
block:
- name: Update pacman and upgrade all packages
community.general.pacman:
update_cache: yes
upgrade: yes
become: yes
- name: Ensure pacman packages are installed
community.general.pacman:
name:
- base-devel
- git
- bash
- bash-completion
- zsh
- zsh-completions
- fish
- vim
- nano
- pwgen
- openssl
- gettext
- helm
- curl
- wget
- tmux
- yamllint
- jq
- tree
- htop
- kubectl
- dnsutils
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
become: yes
- name: Ensure these packages from AUR are not installed using a yay AUR helper
community.general.pacman:
name:
- rancher-k3d-bin
state: removed
executable: yay
- name: Install packages from AUR using a yay AUR helper
community.general.pacman:
name:
- git-secrets
state: latest
executable: yay
when: ( ansible_distribution == 'Archlinux' )
- name: When Rocky 8 ensure dnf packages are installed
block:
- name: Update dnf and upgrade all packages
ansible.builtin.dnf:
update_cache: yes
name: '*'
state: latest
become: yes
- name: Ensure Development tools are installed
ansible.builtin.dnf:
name: '@Development tools'
state: present
become: yes
- name: "Ensure /usr/local/bin is included in PATH"
block:
- lineinfile:
dest: "{{ HOME }}/.bash_profile"
regexp: "^export PATH=/usr/local/bin:$PATH"
state: absent
- lineinfile:
dest: "{{ HOME }}/.bash_profile"
line: "export PATH=/usr/local/bin:$PATH"
insertafter: EOF
become: yes
- name: Ensure latest Bash is installed
block:
- name: Get stats for /usr/local/bin/bash
ansible.builtin.stat:
path: /usr/local/bin/bash
register: st
- name: Install bash-5.1.8 from source
ansible.builtin.shell: |
cd /tmp
wget https://ftp.gnu.org/gnu/bash/bash-5.1.8.tar.gz
tar -zxvf bash-5.1.8.tar.gz
cd bash-5.1.8/
./configure
make
make install
ln -sfn /usr/local/bin/bash /bin/bash
cd /tmp
rm -Rf bash-5.1.8.tar.gz bash-5.1.8
become: yes
when: not st.stat.exists
- name: Ensure Helm 3 is installed
block:
- name: Get stats for /usr/local/bin/helm
ansible.builtin.stat:
path: /usr/local/bin/helm
register: st
- name: Install helm via install script
ansible.builtin.shell: |
PATH=/usr/local/bin:$PATH
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
rm get_helm.sh
become: yes
when: not st.stat.exists
- name: Ensure kubectl is installed
block:
- name: Get stat for /usr/local/bin/kubectl
ansible.builtin.stat:
path: /usr/local/bin/kubectl
register: st
- name: Install latest stable kubectl via install script
ansible.builtin.shell: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
become: yes
when: not st.stat.exists
- name: Ensure git-secrets is installed
block:
- name: Get stat for /usr/local/bin/kubectl
ansible.builtin.stat:
path: /usr/local/bin/git-secrets
register: st
- name: Install git-secrets from source
ansible.builtin.shell: |
cd /tmp
git clone --depth 1 https://github.com/awslabs/git-secrets.git
cd git-secrets/
sudo make install
cd /tmp
rm -Rf git-secrets
become: yes
when: not st.stat.exists
- name: Ensure dnf packages are installed
ansible.builtin.dnf:
name:
- zsh
- nano
- pwgen
- tmux
- yamllint
- jq
- tree
- htop
- bind-utils
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
become: yes
- name: Ensure fish is installed
block:
- name: Get stats for /bin/fish
ansible.builtin.stat:
path: /bin/fish
register: st
- name: Install fish via rpm from opensuse
ansible.builtin.shell: |
cd /etc/yum.repos.d/
wget https://download.opensuse.org/repositories/shells:fish:release:3/CentOS_8/shells:fish:release:3.repo
yum install -y fish
args:
executable: /bin/bash
become: yes
when: not st.stat.exists
when: ( ansible_distribution == 'Rocky' )
- name: Ensure k3d is installed
ansible.builtin.shell: |
PATH=/usr/local/bin:$PATH
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | TAG={{ k3d_release_tag }} bash
args:
executable: /bin/bash
become: yes
- name: Ensure Oh My Zsh is installed and configured
block:
- name: Get stat for {{ HOME }}/.oh-my-zsh
ansible.builtin.stat:
path: "{{ HOME }}/.oh-my-zsh"
register: oh_my_zsh
- name: Git clone https://github.com/ohmyzsh/ohmyzsh.git to {{ HOME }}/.oh-my-zsh, if needed
ansible.builtin.git:
repo: "https://github.com/ohmyzsh/ohmyzsh.git"
dest: "{{ HOME }}/.oh-my-zsh"
when: not oh_my_zsh.stat.exists
# https://www.nerdfonts.com/font-downloads
#
- name: When MacOSX ensure Meslo Nerd Font is installed as it is used by both Powerlevel10k and Tide shell themes
block:
- name: Tap homebrew/cask-fonts
community.general.homebrew_tap:
name: homebrew/cask-fonts
state: present
- ansible.builtin.debug:
msg: Ignore error if the fonts have already been installed...
- name: Install font-hack-nerd-font
community.general.homebrew_cask:
name: font-meslo-lg-nerd-font
state: present
ignore_errors: yes
when: ansible_distribution == 'MacOSX'
- name: When Archlinux ensure Meslo Nerd Font is installed as it is used by both Powerlevel10k and Tide shell themes
block:
- debug:
msg: "Installing nerd-fonts-complete to get all the fonts vice just nerd-fonts-meslo. This may take a while..."
- name: Installing nerd-font-complete via yay AUR helper
community.general.pacman:
name: nerd-fonts-complete
state: latest
executable: yay
when: ansible_distribution == 'Archlinux' and not vagrant_enabled
- name: When Rocky 8 ensure Meslo Nerd Font is installed as it is used by both Powerlevel10k and Tide shell themes
block:
## Only pull stat on font directory not contents this may cause issues...
- name: Get stat for /usr/local/share/fonts/NerdFonts
ansible.builtin.stat:
path: /usr/local/share/fonts/NerdFonts
register: st
- name: Ensure nerd fonts are installed
block:
- debug:
msg: "Installing nerd-fonts-complete to get all the fonts vice just nerd-fonts-meslo. This may take a while..."
- name: Installing nerd-font-complete via install script
ansible.builtin.shell: |
cd /tmp
git clone --depth 1 https://github.com/ryanoasis/nerd-fonts
cd nerd-fonts
./install.sh -S
cd /tmp
rm -Rf nerd-fonts
become: yes
when: not st.stat.exists
when: ansible_distribution == 'Rocky' and not vagrant_enabled
- name: Ensure Powerlevel10k theme is installed for Zsh
block:
- name: Ensure {{ HOME }}/.config path exists
ansible.builtin.file:
path: "{{ HOME }}/.config"
state: directory
- name: Shallow git clone https://github.com/romkatv/powerlevel10k.git
ansible.builtin.git:
repo: "https://github.com/romkatv/powerlevel10k.git"
dest: "{{ HOME }}/.config/powerlevel10"
depth: 1
force: yes
# See: https://github.com/jorgebucaran/fisher
#
- name: Ensure Fisher is installed
ansible.builtin.shell: 'fish -c "curl --insecure -fsSL https://git.io/fisher | source && fisher install jorgebucaran/fisher"'
# See: https://github.com/oh-my-fish/oh-my-fish
#
- name: Ensure Oh My Fish is installed
block:
- name: Get stat on {{ HOME }}/.local/share/omf
ansible.builtin.stat:
path: "{{ HOME }}/.local/share/omf"
register: omf
- name: Install Oh My Fish, if not installed
ansible.builtin.shell: sh -c "curl --insecure -fsSL https://get.oh-my.fish > ~/omf_install && fish ~/omf_install --yes --noninteractive && rm ~/omf_install"
when: not omf.stat.exists
- name: Ensure Tide theme for fish is installed
block:
- name: Ensure Tide theme for fish is installed
ansible.builtin.shell: 'fish -c "fisher install IlanCosman/tide"'
- name: Msg user
ansible.builtin.debug:
msg: If fish is your shell, run `tide configure` afterward to open Tide's config wizard in your terminal.
# As per https://docs.docker.com/docker-for-mac/#bash
#
- name: When MacOSX ensure bash completions exist for Docker Desktop
block:
- name: Ensure bash completions for docker are configured
ansible.builtin.file:
src: /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion
dest: "{{ HOMEBREW_PREFIX }}/etc/bash_completion.d/docker"
state: link
- name: Ensure bash completions for docker-compose are configured
ansible.builtin.file:
src: /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion
dest: "{{ HOMEBREW_PREFIX }}/etc/bash_completion.d/docker-compose"
state: link
when: ( ansible_distribution == 'MacOSX' )
- name: When Archlinux or Rocky 8 ensure bash completions exist for Docker
block:
- ansible.builtin.file:
path: /etc/bash_completion.d
state: directory
become: yes
- ansible.builtin.get_url:
url: https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker
dest: /etc/bash_completion.d/docker
become: yes
when: ( ansible_distribution == 'Archlinux' ) or ( ansible_distribution == 'Rocky' )
# As per https://docs.docker.com/docker-for-mac/#zsh
#
- name: When MacOSX ensure zsh completions exist for Docker Desktop
block:
- name: Ensure zsh completions for docker is configured
ansible.builtin.file:
src: /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion
dest: "{{ HOMEBREW_PREFIX }}/share/zsh/site-functions/_docker"
state: link
- name: Ensure zsh completions for docker-compose is configured
ansible.builtin.file:
src: /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion
dest: "{{ HOMEBREW_PREFIX }}/share/zsh/site-functions/_docker-compose"
state: link
when: ( ansible_distribution == 'MacOSX' )
# As per https://docs.docker.com/docker-for-mac/#fish-shell
#
- name: When MacOSX ensure fish completions for Docker Desktop exist
block:
- name: Ensure fish completions directory exists
ansible.builtin.file:
path: ~/.config/fish/completions
state: directory
- name: Ensure bash completions for docker is configured
ansible.builtin.file:
src: /Applications/Docker.app/Contents/Resources/etc/docker.fish-completion
dest: ~/.config/fish/completions/docker.fish
state: link
- name: Ensure bash completions for docker-compose is configured
ansible.builtin.file:
src: /Applications/Docker.app/Contents/Resources/etc/docker-compose.fish-completion
dest: ~/.config/fish/completions/docker-compose.fish
state: link
when: ( ansible_distribution == 'MacOSX' )
- name: When Archlinux or Rocky 8 ensure fish completions exist for Docker
block:
- ansible.builtin.file:
path: "{{ HOME }}/.config/fish/completions"
state: directory
- ansible.builtin.get_url:
url: https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/fish/docker.fish
dest: "{{ HOME }}/.config/fish/completions/docker.fish"
when: ( ansible_distribution == 'Archlinux' ) or ( ansible_distribution == 'Rocky' )
- name: Ensure fish completions for k3d is configured
block:
- name: Ensure fish completions directory exists
ansible.builtin.file:
path: ~/.config/fish/completions
state: directory
- name: Ensure fish completions for k3d is configured
shell: k3d completion fish >> ~/.config/fish/completions/k3d.fish
# As per `kubectl completion --help`
#
- name: When MacOSX ensure bash completions for kubectl is configured
ansible.builtin.shell: bash -c "kubectl completion bash > {{ HOMEBREW_PREFIX }}/etc/bash_completion.d/kubectl"
when: ( ansible_distribution == 'MacOSX' )
- name: When Archlinux or Rocky 8 ensure bash completions for kubectl is configured
block:
- ansible.builtin.file:
path: /etc/bash_completion.d
state: directory
become: yes
- ansible.builtin.shell: |
PATH=/usr/local/bin:$PATH
kubectl completion bash >/etc/bash_completion.d/kubectl
args:
executable: /bin/bash
become: yes
when: ( ansible_distribution == 'Archlinux' ) or ( ansible_distribution == 'Rocky' )
# There are no batteries included fish completions for kubectl, but @evanlucas maintains a project in regards. Thank you @evanlucas.
#
- name: Ensure fish completions for kubectl is configured
block:
- name: Check if {{ HOME }}/.config/fish/completions/kubectl.fish exists
ansible.builtin.stat:
path: "{{ HOME }}/.config/fish/completions/kubectl.fish"
register: fish_completions_kubectl
- ansible.builtin.shell: 'fish -c "fisher install evanlucas/fish-kubectl-completions"'
when: not fish_completions_kubectl.stat.exists