-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathworkstation-headless.yml
339 lines (312 loc) · 10.1 KB
/
workstation-headless.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
---
- name: Configure Fedora workstation (headless)
hosts: workstation-headless
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: 'vimdiff'
git_push_default: 'current'
authorized_keys: '{{ lookup("file", "files/id_rsa.pub") }}'
handlers:
- 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:
- clang
- cloud-utils
- cmake
- cockpit
- cockpit-machines
- containerd.io
- curl
- dnsutils
- docker-buildx-plugin
- docker-ce
- docker-ce-cli
- docker-compose-plugin
- firewalld
- fzf
- git
- git-extras
- gnupg
- guestfs-tools
- htop
- libvirt
- make
- micro
- ncdu
- nmap
- openvpn
- pinentry-tty
- python3
- python3-pip
- qemu-img
- qemu-kvm
- rubygems
- terraform
- tmux
- traceroute
- unzip
- virt-install
- 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: Enable and start Docker-CE service
service:
name: docker
state: started
enabled: yes
become: yes
- name: Enable and start libvirtd
service:
name: libvirtd
state: started
enabled: yes
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: 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: 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 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' ]
- 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' ]
- 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
- cockpit
become: yes
tags: [ 'firewall' ]
- name: Set GoAway as default policy
command: firewall-cmd --set-default-zone=GoAway
become: yes
tags: [ 'firewall' ]