-
Notifications
You must be signed in to change notification settings - Fork 14
/
playbook_core.yml
439 lines (361 loc) · 12.6 KB
/
playbook_core.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
---
- name: playbook_core.yml - archlinux base setup
hosts: all
become: yes
tasks:
# ARCH FULL UPDATE ----------------------------------------------------------
- name: update arch
pacman:
update_cache: yes
upgrade: yes
# INSTALL VARIOUS PACKAGES --------------------------------------------------
- name: install bunch of packages
pacman:
update_cache: yes
name:
- nano # editor
- micro # editor
- man-db # help pages
- git # to clone github repos
- curl # download utility
- wget # download utility
- rsync # copy utility
- nnn # file manager
- fd # simpler find
- fzf # fuzzy filter, useful for file search
- bat # prettier cat
- tree # show files/directories structure
- unarchiver # extract any archive
- fastfetch # system info
- duf # prettier df
- ncdu # investigate disk usage
- htop # resource monitor
- btop # better resource monitor
- glances # system monitor
- iotop # disk use monitor
- nethogs # network monitor per process
- nmap # network scan
- gnu-netcat # diagnose network issues using tiny server
- tcpdump # diagnose network issues by wathing ports
- net-tools # network utilities like arp, netstat
- iproute2 # network utilities like ss
- bind # DNS utilities, like nslookup
- nload # monitor bandwidth
- sysfsutils # utility to deal with sysfs
- lsof # list open files
- fuse # mounting file systems
- sqlite # simple database and utilities for it
- python-llfuse # bindings for fuse mounting
- python-pip # package manager
- python-setuptools # additional packaging tools
- python-pexpect # child application control
# YAY TO ACCESS AUR REPOSITORY ----------------------------------------------
- name: disable need for password for pacman to allow yay install
lineinfile:
path: /etc/sudoers.d/temp_allow_no_pswd_pacman
state: present
line: "ALL ALL=NOPASSWD: /usr/bin/pacman"
validate: /usr/sbin/visudo -cf %s
create: yes
- name: git clone yay-bin repo in to /tmp
become: no
git:
repo: 'https://aur.archlinux.org/yay-bin.git'
dest: /tmp/yay-bin
clone: yes
- name: install yay using makepkg
become: no
expect:
chdir: /tmp/yay-bin
command: makepkg -si
responses:
(?i)Proceed with installation: "y"
- name: re-enable need for password for pacman
file:
path: /etc/sudoers.d/temp_allow_no_pswd_pacman
state: absent
- name: set yay options to cleanafter package installation
become: no
shell: yay -Y --answerclean All --removemake --cleanafter --save
args:
executable: /usr/bin/bash
# SYSTEM SETTINGS CHANGES ----------------------------------------------------
- name: pacman - enable color
lineinfile:
path: /etc/pacman.conf
regexp: '^#Color$'
line: 'Color'
- name: pacman - enable ParallelDownloads = 5
lineinfile:
path: /etc/pacman.conf
regexp: '#ParallelDownloads = 5'
line: 'ParallelDownloads = 5'
- name: makepkg - disable compression
lineinfile:
path: /etc/makepkg.conf
regexp: "PKGEXT='.pkg.tar.zst'"
line: "PKGEXT='.pkg.tar'"
- name: makepkg - enable parallel compilation MAKEFLAGS="-j$(nproc)"
lineinfile:
path: /etc/makepkg.conf
regexp: '#MAKEFLAGS="-j2"'
line: 'MAKEFLAGS="-j$(nproc)"'
- name: fstab change relatime to noatime
replace:
path: /etc/fstab
regexp: 'relatime'
replace: 'noatime'
- name: change number of failed logins that triger 10min lockout
lineinfile:
path: /etc/security/faillock.conf
regexp: '^# deny = 3$'
line: 'deny = 10'
- name: enable members of wheel group to sudo
lineinfile:
path: /etc/sudoers.d/01_wheel_allow_sudo
state: present
line: "%wheel ALL=(ALL:ALL) ALL"
validate: /usr/sbin/visudo -cf %s
create: yes
# USERS PERMISSIONS ---------------------------------------------------------
- name: add the user to the root group
user:
name: "{{ ansible_user }}"
groups: root
append: yes
- name: disable need for sudo password for the current user
lineinfile:
path: "/etc/sudoers.d/02_no_pswd_for_{{ ansible_env.SUDO_UID }}"
state: present
line: "{{ ansible_user }} ALL=(ALL:ALL) NOPASSWD: ALL"
validate: /usr/sbin/visudo -cf %s
create: yes
# SSH ------------------------------------------------------------------------
- name: install ssh
pacman:
name:
- openssh
- name: enable and start ssh service
systemd:
name: sshd
enabled: yes
state: started
# NNN ------------------------------------------------------------------------
- name: install nnn
pacman:
name:
- nnn
- name: install nnn plugins
become: no
shell: "curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh"
# LOCATE THE QUICK FILE SEARCH ----------------------------------------------
- name: install plocate
pacman:
name:
- plocate
- name: enable and start ~12h updatedb timer
systemd:
name: plocate-updatedb.timer
enabled: yes
state: started
# CRONIE --------------------------------------------------------------------
- name: install cronie
pacman:
name:
- cronie
- name: enable and start cronie.service
systemd:
name: cronie
enabled: yes
state: started
# ARCHLINUX-KEYRING WEEKLY UPDATE -------------------------------------------
- name: archlinux-keyring - enable weekly update
systemd:
name: archlinux-keyring-wkd-sync.timer
enabled: yes
state: started
# SSD TRIM SCHEDULED --------------------------------------------------------
- name: install util-linux
pacman:
name:
- util-linux
- name: enable and start weekly ssd disks trim using fstrim timer
systemd:
name: fstrim.timer
enabled: yes
state: started
# TRASH SETUP ----------------------------------------------------------------
- name: install trash-cli
pacman:
name:
- trash-cli
- name: create trash-empty.service file
copy:
dest: '/etc/systemd/system/trash-empty.service'
content: |
[Unit]
Description=Empty trash older than 30 days
[Service]
Type=oneshot
ExecStart=/usr/bin/trash-empty 30
- name: create trash-empty.timer file
copy:
dest: '/etc/systemd/system/trash-empty.timer'
content: |
[Unit]
Description=Empty trash older than 30 days daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
- name: enable and start trash-empty.timer
systemd:
name: trash-empty.timer
enabled: yes
state: started
# CACHE CLEANER SCHEDULED ---------------------------------------------------
- name: install pacman-contrib
pacman:
name:
- pacman-contrib
- name: enable and start weekly cache cleanup paccache timer
systemd:
name: paccache.timer
enabled: yes
state: started
# REFLECTOR TO REGULARLY UPDATE MIRRORLIST ---- CHANGE COUNTRY CODES !!! ----
- name: install reflector
pacman:
name:
- reflector
- name: write reflector configuration file
copy:
dest: '/etc/xdg/reflector/reflector.conf'
content: |
--save /etc/pacman.d/mirrorlist
--protocol http
--country SK,CZ
--score 20
--sort rate
- name: enable and start reflector timer
systemd:
name: reflector.timer
enabled: yes
state: started
- name: do initial run of reflector.service
systemd:
name: reflector
enabled: yes
state: started
# LOGROTATE -----------------------------------------------------------------
- name: install logrotate
pacman:
name:
- logrotate
- name: logrotate - enable compression
lineinfile:
path: /etc/logrotate.conf
regexp: '^#compress$'
line: 'compress'
- name: enable and start daily logs rotation, cleanup
systemd:
name: logrotate.timer
enabled: yes
state: started
# NEOFETCH ------------------------------------------------------------------
- name: install neofetch
pacman:
name:
- neofetch
- name: run neofetch to generate config
become: no
command: neofetch
- name: enable disk info in neofetch
become: no
lineinfile:
path: ~/.config/neofetch/config.conf
regexp: '.*# info "Disk" disk$'
line: ' info "Disk" disk'
- name: enable local IP info in neofetch
become: no
lineinfile:
path: ~/.config/neofetch/config.conf
regexp: '.*# info "Local IP" local_ip$'
line: ' info "Local IP" local_ip'
# HYPERV --------------------------------------------------------------------
- name: if hyperv, install hyperv package
pacman:
name:
- hyperv
when:
- ansible_facts['virtualization_role'] == 'guest'
- ansible_facts['virtualization_type'] == 'VirtualPC'
- name: if hyperv, enable and start hyperv integration services
systemd:
name: "{{ item }}"
enabled: yes
state: started
with_items:
- hv_fcopy_daemon.service
- hv_kvp_daemon.service
- hv_vss_daemon.service
when:
- ansible_facts['virtualization_role'] == 'guest'
- ansible_facts['virtualization_type'] == 'VirtualPC'
# VMWARE --------------------------------------------------------------------
- name: if vmware, install open-vm-tools
pacman:
name:
- open-vm-tools
when:
- ansible_facts['virtualization_role'] == 'guest'
- ansible_facts['virtualization_type'] == 'VMware'
- name: if vmware, enable and start vmware open tools services
systemd:
name: "{{ item }}"
enabled: yes
state: started
with_items:
- vmtoolsd.service
- vmware-vmblock-fuse.service
when:
- ansible_facts['virtualization_role'] == 'guest'
- ansible_facts['virtualization_type'] == 'VMware'
# VIRTUALBOX ---------------------------------------------------------------
- name: if virtualbox, install guest additions NON-X version
pacman:
name:
- virtualbox-guest-utils-nox
when:
- ansible_facts['virtualization_role'] == 'guest'
- ansible_facts['virtualization_type'] == 'virtualbox'
- name: if virtualbox, enable and start vboxservice
systemd:
name: "{{ item }}"
enabled: yes
state: started
with_items:
- vboxservice.service
when:
- ansible_facts['virtualization_role'] == 'guest'
- ansible_facts['virtualization_type'] == 'virtualbox'
# SETUP MICRO TEXT EDITOR ---------------------------------------------------
- name: install micro text editor
pacman:
name:
- micro
- name: copy config directory with prefernces, hotkeys, syntax highlight
become: no
copy:
src: .config/micro
dest: ~/.config
mode: 0644
- name: set default editor in .bashrc
become: no
blockinfile:
path: ~/.bashrc
block: |
export EDITOR=micro
export VISUAL=micro
# ---------------------------------------------------------------------------