forked from nemonik/hands-on-DevOps-gen2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.yaml
319 lines (276 loc) · 11.5 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
---
- name: Ensure common dependencies are installed
hosts: factory
tasks:
- name: Set fact for $HOME
ansible.builtin.set_fact:
HOME: "{{ lookup('env', 'HOME') }}"
- 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 HomeBrew packages are installed
community.general.homebrew:
name:
- bash
- bash-completion@2
- zsh
- zsh-completion
- fish
- vim
- nano
- pwgen
- openssl
- watch
- gettext
- k3d
- 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
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
become: yes
- name: Install packages from AUR using a yay AUR helper
community.general.pacman:
name:
- rancher-k3d-bin
- git-secrets
state: latest
executable: yay
when: ( ansible_distribution == 'Archlinux' )
- name: Ensure Oh My Zsh is installed and configured
block:
- name: Check if {{ HOME }}/.oh-my-zsh exists
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-comlete via yay AUR helper
community.general.pacman:
name: nerd-fonts-complete
state: latest
executable: yay
when: ansible_distribution == 'Archlinux'
- 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 -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: Check if Oh My Fish is installed
ansible.builtin.stat:
path: "{{ HOME }}/.local/share/omf"
register: omf
- name: Install Oh My Fish, if not installed
ansible.builtin.shell: sh -c "curl -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 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' )
# 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 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' )
- 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 ensure bash completions for kubectl is configured
block:
- ansible.builtin.file:
path: /etc/bash_completion.d
state: directory
become: yes
- ansible.builtin.shell: bash -c "kubectl completion bash >/etc/bash_completion.d/kubectl"
become: yes
when: ( ansible_distribution == 'Archlinux' )
# 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