-
Notifications
You must be signed in to change notification settings - Fork 23
/
workstation.yml
541 lines (497 loc) · 16.7 KB
/
workstation.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
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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
---
- name: Configure Fedora workstation
hosts: workstation
# Edit as needed if executing remotely
remote_user: matiss
vars:
# Update these variables as needed to match your own settings.
host_username: 'matiss'
allow_ssh_users: 'matiss'
git_email: '[email protected]'
git_name: 'Matīss Treinis'
git_signing_key: '3B44AE79519B1C6552941B109123B913EBF53D43'
git_commit_gpgsign: 'true'
git_diff_tool: 'meld'
git_push_default: 'current'
authorized_keys: '{{ lookup("file", "files/id_rsa.pub") }}'
handlers:
- name: Update dconf
shell: dconf update
become: yes
- name: Update initramfs
shell: dracut --regenerate-all --force
become: yes
- name: Restart sshd
service:
name: sshd
state: restarted
become: yes
- name: Reload firewalld
service:
name: firewalld
state: reloaded
become: yes
tasks:
- name: Add RPM keys (.rpm repos)
rpm_key:
state: present
key: '{{item}}'
loop:
- 'https://rpmfusion.org/keys?action=AttachFile&do=get&target=RPM-GPG-KEY-rpmfusion-free-fedora-2020'
- 'https://rpmfusion.org/keys?action=AttachFile&do=get&target=RPM-GPG-KEY-rpmfusion-nonfree-fedora-2020'
- 'https://repo.protonvpn.com/fedora-{{ansible_distribution_major_version}}-stable/public_key.asc'
become: yes
tags: [ 'repositories' ]
- name: Add repositories (.rpm)
dnf:
name: '{{ item }}'
state: present
loop:
- 'https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-{{ansible_distribution_major_version}}.noarch.rpm'
- 'https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-{{ansible_distribution_major_version}}.noarch.rpm'
- 'https://repo.protonvpn.com/fedora-{{ansible_distribution_major_version}}-stable/protonvpn-stable-release/protonvpn-stable-release-1.0.1-2.noarch.rpm'
become: yes
tags: [ 'repositories' ]
- name: Add repositories (.repo)
get_url:
url: '{{item.url}}'
dest: '/etc/yum.repos.d/{{item.name}}.repo'
loop:
- { name: docker-ce, url: 'https://download.docker.com/linux/fedora/docker-ce.repo' }
- { name: hashicorp, url: 'https://rpm.releases.hashicorp.com/fedora/hashicorp.repo' }
become: yes
tags: [ 'repositories' ]
- name: Enable repositories
shell: 'dnf config-manager --set-enabled {{item}}'
loop:
- docker-ce-stable
- rpmfusion-free
- rpmfusion-free-updates
- rpmfusion-nonfree
- rpmfusion-nonfree-updates
- protonvpn-fedora-stable
become: yes
tags: [ 'repositories' ]
changed_when: false
- name: Install workstation packages
package:
name: '{{item}}'
state: latest
loop:
- NetworkManager-openvpn
- NetworkManager-openvpn-gnome
- clang
- cloud-utils
- cmake
- containerd.io
- cups
- curl
- dnsutils
- docker-buildx-plugin
- docker-ce
- docker-ce-cli
- docker-compose-plugin
- file-roller
- filezilla
- firefox
- firewall-config
- firewalld
- fzf
- gimp
- git
- git-extras
- gitg
- gnome-boxes
- gnome-connections
- gnome-extensions-app
- gnome-shell-extension-apps-menu
- gnome-shell-extension-caffeine
- gnome-shell-extension-dash-to-dock
- gnome-shell-extension-user-theme
- gnome-tweaks
- gnupg
- htop
- inkscape
- libreoffice-base
- libreoffice-calc
- libreoffice-impress
- libreoffice-writer
- make
- meld
- micro
- ncdu
- nmap
- openvpn
- p7zip
- papirus-icon-theme
- podman
- polari
- protonvpn-stable-release
- python3
- python3-pip
- rubygems
- seahorse
- terraform
- tmux
- traceroute
- unzip
- virt-manager
- vlc
- wget
- whois
- zip
- zsh
become: yes
tags: [ 'packages' ]
- name: Install ffmpeg with allow erasing
dnf:
name: ffmpeg
state: latest
allowerasing: yes
become: yes
tags: [ 'packages' ]
- name: Install tmuxinator
gem:
name: tmuxinator
state: latest
user_install: false
become: yes
tags: [ 'packages' , 'gem' ]
- name: Ensure pip3 packages
pip:
name: '{{item}}'
executable: pip3
state: latest
loop:
- ansible # Yo dawg i herd you like Ansible so we put a Ansible in yo Ansible so you can automate while u automate
- awscli
- name: Add the Flathub to flatpak remotes
flatpak_remote:
name: flathub
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
state: present
become: yes
tags: [ 'packages', 'flatpak' ]
- name: Install flatpak packages
flatpak:
name:
- com.bitwarden.desktop
- com.mattermost.Desktop
- com.skype.Client
- com.slack.Slack
- com.spotify.Client
- com.valvesoftware.Steam
- org.gnome.World.PikaBackup
- org.signal.Signal
- org.standardnotes.standardnotes
- org.telegram.desktop
- us.zoom.Zoom
become: yes
tags: [ 'packages', 'flatpak' , 'flatpak_packages' ]
- name: Stat /opt/jetbrains-toolbox/
stat:
path: /opt/jetbrains-toolbox/
register: opt_jetbrains_toolbox
tags: [ 'packages', 'toolbox' ]
- name: Create /opt/jetbrains-toolbox/ if not present
file:
path: /opt/jetbrains-toolbox/
state: directory
owner: root
mode: '0775'
when: not opt_jetbrains_toolbox.stat.exists
become: yes
tags: [ 'packages', 'toolbox' ]
- name: Download JB toolbox
unarchive:
src: https://download.jetbrains.com/product?code=TB&latest&distribution=linux
remote_src: true
dest: /opt/jetbrains-toolbox/
owner: '{{host_username}}'
group: '{{host_username}}'
mode: '0755'
when: not opt_jetbrains_toolbox.stat.exists
become: yes
tags: [ 'packages', 'toolbox' ]
- name: Enable and start Docker-CE service
service:
name: docker
state: started
enabled: yes
become: yes
- name: Copy system wallpaper
copy:
src: wallpaper.jpg
dest: /usr/share/backgrounds/wallpaper.jpg
mode: '0644'
owner: root
group: root
become: yes
tags: [ 'wallpaper' ]
- name: Install fonts
copy:
src: fonts/
dest: /usr/local/share/fonts
become: yes
- name: Configure boot screen
copy:
src: plymouthd.conf
dest: /etc/plymouth/plymouthd.conf
mode: '0644'
owner: root
group: root
notify: [ Update initramfs ]
become: yes
- meta: flush_handlers
- name: Install oh-my-zsh for self
script:
cmd: 'scripts/oh-my-zsh-setup.sh --unattended --keep-zshrc'
chdir: '/home/{{host_username}}'
creates: '/home/{{host_username}}/.oh-my-zsh'
changed_when: false # ignore
- name: Install oh-my-zsh for root
script:
cmd: 'scripts/oh-my-zsh-setup.sh --unattended --keep-zshrc'
creates: '/root/.oh-my-zsh'
changed_when: false # ignore
become: yes
- name: Ensure group "docker" exists
group:
name: docker
state: present
become: yes
- name: Configure '{{host_username}}' user settings (zsh, docker group)
user:
name: '{{host_username}}'
shell: /bin/zsh
groups: docker
append: yes
create_home: yes
password: '*' # Initial password is none, account locked
update_password: on_create # Do not reset password from ansible
become: yes
- name: Set root shell to zsh
user:
name: root
shell: /bin/zsh
become: yes
- name: Ensure '/home/{{host_username}}/.ssh/' has correct permissions
file:
path: '/home/{{host_username}}/.ssh'
state: directory
mode: '0700'
owner: '{{host_username}}'
group: '{{host_username}}'
become: yes
- name: Locate all files in '/home/{{host_username}}/.ssh/'
find:
paths: '/home/{{host_username}}/.ssh'
file_type: file
patterns: "*"
register: home_dot_ssh_files
- name: Ensure all files in '/home/{{host_username}}/.ssh/' have correct permissions
file:
path: '{{ item.path }}'
state: file
owner: '{{host_username}}'
group: '{{host_username}}'
mode: '0600'
loop: '{{ home_dot_ssh_files.files }}'
loop_control:
label: '{{item.path}}'
- name: Ensure personal dot files
copy:
src: '{{item.src}}'
dest: '{{item.dest}}'
mode: '0600'
owner: '{{host_username}}'
group: '{{host_username}}'
loop:
- { src: dots/zshrc.zsh, dest: '/home/{{host_username}}/.zshrc' }
- { src: dots/tmux.conf, dest: '/home/{{host_username}}/.tmux.conf' }
- { src: dots/editorconfig, dest: '/home/{{host_username}}/.editorconfig' }
- { src: dots/wgetrc, dest: '/home/{{host_username}}/.wgetrc' }
- { src: dots/gitignore, dest: '/home/{{host_username}}/.gitignore' }
- { src: dots/curlrc, dest: '/home/{{host_username}}/.curlrc' }
tags: [ 'dots' ]
- name: Ensure root dot files
copy:
src: '{{item.src}}'
dest: '{{item.dest}}'
mode: '0600'
owner: root
group: root
loop:
- { src: dots/zshrc.zsh, dest: '/root/.zshrc' }
- { src: dots/editorconfig, dest: '/root/.editorconfig' }
- { src: dots/wgetrc, dest: '/root/.wgetrc' }
- { src: dots/curlrc, dest: '/root/.curlrc' }
become: yes
tags: [ 'dots' ]
- name: Ensure personal files (from templates)
template:
src: '{{item.src}}'
dest: '{{item.dest}}'
mode: '0600'
owner: '{{host_username}}'
group: '{{host_username}}'
loop:
- { src: dots/gitconfig, dest: '/home/{{host_username}}/.gitconfig' }
- { src: dots/authorized_keys, dest: '/home/{{host_username}}/.ssh/authorized_keys' }
- name: Ensure default directories in home
file:
path: '{{item}}'
state: directory
mode: '0700'
owner: '{{host_username}}'
group: '{{host_username}}'
loop:
- '/home/{{host_username}}/dots'
- '/home/{{host_username}}/Projects'
- '/home/{{host_username}}/Projects/Work'
- '/home/{{host_username}}/Projects/Work/Archive'
- '/home/{{host_username}}/Projects/Work/Scratch'
- '/home/{{host_username}}/Projects/Personal'
- '/home/{{host_username}}/Projects/Personal/Archive'
- '/home/{{host_username}}/Projects/Personal/Scratch'
- '/home/{{host_username}}/Documents/Work/Archive'
- '/home/{{host_username}}/Documents/Personal/Archive'
become: yes
tags: [ 'dir-structure' ]
# Configure icons in Nautilus for some directories.
- name: Set home folder icons
shell: 'gio set -t string {{item.dir}} metadata::custom-icon file://{{item.icon}}'
changed_when: false # Really not that important...
loop:
- { dir: '/home/{{host_username}}/dots', icon: '/usr/share/icons/Papirus/64x64/places/folder-orange-sync.svg' }
- { dir: '/home/{{host_username}}/Projects', icon: '/usr/share/icons/Papirus/64x64/places/folder-magenta-projects.svg' }
- { dir: '/home/{{host_username}}/Projects/Work', icon: '/usr/share/icons/Papirus/64x64/places/folder-red-projects.svg' }
- { dir: '/home/{{host_username}}/Projects/Work/Archive', icon: '/usr/share/icons/Papirus/64x64/places/folder-red-tar.svg' }
- { dir: '/home/{{host_username}}/Projects/Work/Scratch', icon: '/usr/share/icons/Papirus/64x64/places/folder-red-java.svg' }
- { dir: '/home/{{host_username}}/Projects/Personal', icon: '/usr/share/icons/Papirus/64x64/places/folder-teal-projects.svg' }
- { dir: '/home/{{host_username}}/Projects/Personal/Archive', icon: '/usr/share/icons/Papirus/64x64/places/folder-teal-tar.svg' }
- { dir: '/home/{{host_username}}/Projects/Personal/Scratch', icon: '/usr/share/icons/Papirus/64x64/places/folder-teal-java.svg' }
- { dir: '/home/{{host_username}}/Documents/Work', icon: '/usr/share/icons/Papirus/64x64/places/folder-red-documents.svg' }
- { dir: '/home/{{host_username}}/Documents/Work/Archive', icon: '/usr/share/icons/Papirus/64x64/places/folder-red-tar.svg' }
- { dir: '/home/{{host_username}}/Documents/Personal', icon: '/usr/share/icons/Papirus/64x64/places/folder-teal-documents.svg' }
- { dir: '/home/{{host_username}}/Documents/Personal/Archive', icon: '/usr/share/icons/Papirus/64x64/places/folder-teal-tar.svg' }
tags: [ 'dir-structure' ]
- name: Ensure dconf profile directory exists
file:
path: /etc/dconf/profile
state: directory
mode: '0755'
owner: root
group: root
become: yes
tags: [ 'dconf' ]
- name: Copy dconf user profile configuration
copy:
src: dconf_profile_user
dest: /etc/dconf/profile/user
mode: '0644'
owner: root
group: root
become: yes
tags: [ 'dconf' ]
- name: Ensure dconf local configuration defaults exists
file:
path: /etc/dconf/db/local.d
state: directory
mode: '0755'
owner: root
group: root
become: yes
tags: [ 'dconf' ]
- name: Configure dconf global defaults
copy:
src: dconf_settings.ini
dest: /etc/dconf/db/local.d/00-global
mode: '0644'
owner: root
group: root
notify: [ Update dconf ]
become: yes
tags: [ 'dconf' ]
- name: Configure GDM dconf settings defaults
copy:
src: dconf_gdm.ini
dest: /etc/dconf/db/gdm.d/00-global
mode: '0644'
owner: root
group: root
notify: [ Update dconf ]
become: yes
tags: [ 'dconf' ]
- meta: flush_handlers
- name: Ensure local sshd config exists with the right perms
file:
path: /etc/ssh/sshd_config.d/00-local.conf
state: touch
mode: '0700'
owner: root
group: root
modification_time: preserve
access_time: preserve
become: yes
tags: [ 'sshd' ]
- name: Set local sshd config
lineinfile:
path: /etc/ssh/sshd_config.d/00-local.conf
regexp: '^{{item.key}}'
line: '{{item.key}} {{item.value}}'
state: present
become: yes
loop:
- { key: 'PasswordAuthentication', value: 'no' }
- { key: 'PermitEmptyPasswords', value: 'no' }
- { key: 'GSSAPIAuthentication', value: 'no' }
- { key: 'ChallengeResponseAuthentication', value: 'no' }
- { key: 'KerberosAuthentication', value: 'no' }
- { key: 'PermitRootLogin', value: 'no' }
- { key: 'X11Forwarding', value: 'no' }
- { key: 'AllowTcpForwarding', value: 'yes' }
- { key: 'ClientAliveCountMax', value: '3' }
- { key: 'ClientAliveInterval', value: '300' }
- { key: 'LoginGraceTime', value: '15' }
- { key: 'Ciphers', value: '[email protected],[email protected],aes256-ctr,[email protected],aes128-ctr' }
- { key: 'MACs', value: '[email protected],[email protected],hmac-sha2-256,hmac-sha2-512' }
- { key: 'KexAlgorithms', value: '[email protected]' }
- { key: 'AllowUsers', value: '{{allow_ssh_users}}' }
notify: [ Restart sshd ]
tags: [ 'sshd' ]
- name: Ensure firewalld is running
service:
name: firewalld
state: started
enabled: yes
become: yes
tags: [ 'firewall' ]
- meta: flush_handlers
- name: Create custom zone to use by default
firewalld:
zone: GoAway
state: present
permanent: true
become: yes
notify: [ Reload firewalld ]
tags: [ 'firewall' ]
- meta: flush_handlers
- name: Allow basic services in firewall
firewalld:
service: '{{item}}'
permanent: yes
state: enabled
immediate: yes
zone: GoAway
loop:
- dhcpv6-client
- mdns
- samba-client
- ssh
become: yes
tags: [ 'firewall' ]
- name: Set GoAway as default policy
command: firewall-cmd --set-default-zone=GoAway
become: yes
tags: [ 'firewall' ]