-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.yml
567 lines (565 loc) · 15.7 KB
/
main.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
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
---
- name: Ansible-decent-desktop
hosts: all
become: true
gather_facts: true
roles:
- role: debops.debops.apt_preferences
tags:
- repos
- role: debops.debops.extrepo
tags:
- repos
- role: debops.debops.apt_install
tags:
- packages
# TODO enable and move to systemd-boot
# - boot_manager
- role: debops.debops.grub
tags:
- boot
- role: debops.debops.apt
tags:
- repos
- role: debops.debops.unattended_upgrades
tags:
- unattended-upgrades
- role: debops.debops.libuser
tags:
- users
- role: debops.debops.users
tags:
- users
- role: debops.debops.system_groups
tags:
- users
- groups
- role: debops.debops.locales
tags:
- locale
- role: additional_locales
tags:
- locale
- role: dm
tags:
- dm
- debops.debops.sysctl
- role: debops.debops.secret
vars:
secret__directories:
- sysfs/dependent_config/{{ inventory_hostname }}
- debops.debops.sysfs
- role: devsec.hardening.ssh_hardening
tags:
- hardering
- logind
- role: debops.debops.journald
tags:
- logs
- role: debops.debops.logrotate
tags:
- logs
- role: networking
tags:
- networking
- role: mullvad
when: mullvad_account is defined and mullvad_account != ''
tags:
- mullvad
- role: audio
tags:
- audio
# - role: firewall
# tags:
# - firewall
- role: timezone
tags:
- time
- role: debops.debops.ntp
tags:
- time
- role: de
tags:
- de
- role: packages
tags:
- packages
- debops.debops.kmod
- role: debops.debops.python
tags:
- python
- role: themes
tags:
- theme
- role: fonts
tags:
- fonts
- role: hardware
tags:
- hardware
- gantsign.keyboard
- role: apparmor_profiles
tags:
- hardering
- apparmor
- role: games
tags:
- games
- role: devsec.hardening.os_hardening
tags:
- hardering
vars:
large_dirs: /home/{{ username }}
local_ip: 192.168.0.0/16
architecture_map:
x86_64: amd64
armv7l: armhf
aarch64: arm64
nonfree_firmware: true
tor_browser_user_agent: Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0
timezone: Etc/UTC
# gantsign.keyboard vars
keyboard_model: pc105
keyboard_layout: us,ru
keyboard_options: grp:caps_toggle,compose:ralt,grp_led:scroll
# dev-sec vars
sysctl_overwrite:
net.ipv6.conf.all.disable_ipv6: 0
net.ipv4.ip_forward: 1
kernel.unprivileged_userns_clone: 1
net.ipv4.conf.all.log_martians: 0
net.ipv4.conf.default.log_martians: 0
# https://kspp.github.io/Recommended_Settings#sysctls
kernel.dmesg_restrict: 1
kernel.yama.ptrace_scope: 3
net.core.bpf_jit_harden: 2
vm.unprivileged_userfaultfd: 0
fs.protected_fifos: 2
dev.tty.legacy_tiocsti: 0
dev.tty.ldisc_autoload: 0
kernel.unprivileged_bpf_disabled: 1
os_auth_retries: 10
os_filesystem_whitelist:
- squashfs
os_desktop_enable: true
ufw_manage_defaults: false
ssh_server_enabled: false
ssh_server_hardening: false
ssh_use_dns: true
ssh_client_hardening: true
ssh_client_password_login: true
os_auditd_enabled: false
hidepid_option: 0
# debops vars
extrepo__packages:
- tor
- apt-transport-tor
- extrepo-offline-data
extrepo__sources:
- fasttrack_backports
- josm
- node_21.x
- yarnpkg
- whonix
- kicksecure
- waydroid
- vscodium
extrepo__configuration:
- name: policies
config:
enabled_policies: [main]
sysfs__enabled: true
ntp__daemon_enabled: true
ntp__daemon: chrony
ntp__timezone: "{{ timezone }}"
journald__configuration:
- name: SystemMaxUse
value: 500M
state: present
- name: SystemKeepFree
value: 3G
state: present
- name: SystemMaxFiles
value: 10
state: present
- name: MaxFileSec
value: 3day
state: present
logrotate__config:
- state: present
options: |
daily
rotate 2
create
compress
maxage 3
shred
tabooext + .dpkg-divert
include /etc/logrotate.d
system_groups__list:
- name: console
members: "{{ username }}"
users__accounts:
- name: "{{ username }}"
group: "{{ username }}"
groups:
- cdrom
- floppy
- sudo
- audio
- video
- plugdev
- netdev
- lpadmin
- console
- wireshark
- debian-tor
- docker
shell: /bin/bash
packages:
- tirdad
- kloak
- micro
- bat
- lsd
- duf
- tldr
- flatpak
- systemd
- systemd-sysv
- jitterentropy-rngd
- whois
- plocate
- jq
- pavucontrol
- ffmpeg
- git
- htop
- curl
- wget
- openssh-client
- unar
- suckless-tools
- libavcodec-extra
- gstreamer1.0-libav
- gstreamer1.0-vaapi
- gstreamer1.0-plugins-base
- gstreamer1.0-plugins-good
- gstreamer1.0-plugins-bad
- gstreamer1.0-plugins-ugly
- ripgrep
- dnsutils
- udevil
- gvfs
- gvfs-backends
- imv
- pngquant
- optipng
- jpegoptim
- mat2
- nnn
- g++
- gcc
- make
- needrestart
- lm-sensors
- shellcheck
- wireshark
- devscripts
- build-essential
- debhelper
- secure-delete
- command-not-found
- apt-file
- direnv
- libvips-tools
- p7zip-full
- openclipart-svg
- v4l2loopback-dkms
- timidity
- fluid-soundfont-gm
- mate-polkit
apt_install__all_packages:
- "{{ packages }}"
apt_preferences__list:
- packages:
- yt-dlp
- streamlink
- python3-streamlink
- runsc
- telegram-desktop
- scrcpy
- scrcpy-*
- dino-im
- dino-im-*
- bubblewrap
- flatpak
- flatpak-*
- libflatpak-*
- libflatpak0
- xdg-desktop-portal
- xdg-desktop-portal-*
- josm
- josm-*
- jmapviewer
# libreoffice
- uno-libs-private
- ure
- ure-java
- liblibreoffice-*
- libunoloader-java
- python3-uno
- libreoffice-*
- libofficebean-java
- libuno-*
- 0ad
- 0ad-*
- syncthing
- syncthing-*
- persepolis
# backported kernel
- linux-compiler-gcc-*
- linux-headers-*
- linux-image-*
- linux-kbuild-*
- linux-config-*
- linux-doc-*
- kernel-image-*
- linux-doc
- linux-libc-dev
# systemd
- systemd
- systemd-*
- libnss-systemd
- libpam-systemd
- libsystemd-*
- libsystemd0
- dbus-broker
- init-system-helpers
# pipewire
- pipewire
- wireplumber
- libpipewire-*
- libwireplumber-*
- pipewire-*
- libspa-0.2-*
- wireplumber-*
- easyeffects
- sqlcipher
- golang
- golang-*
- tlp
- tlp-*
- smartmontools
- glab
- firmware-*
# wayland
- wayland-protocols
- libwayland-*
- electrum
- python3-electrum
suffix: _backports
backports: [bookworm]
- "{{ apt_preferences__preset_list | list }}"
- suffix: _tor
raw: |
Explanation: Prefer official tor packages
Package: tor deb.torproject.org-keyring tor-dbgsym tor-geoipdb
Pin: release o=TorProject,n={{ ansible_distribution_release }}
Pin-Priority: 600
- suffix: _nodejs
raw: |
Explanation: Prefer nodesource packages
Package: nodejs nsolid
Pin: release a=nodistro,n=nodistro
Pin-Priority: 600
- suffix: _yarn
raw: |
Explanation: Prefer official yarn package
Package: yarn
Pin: release o=yarn
Pin-Priority: 600
- suffix: _josm
raw: |
Explanation: Prefer official josm packages
Package: josm josm-latest
Pin: release n=alldist
Pin-Priority: 600
apt_install__default_alternatives: []
apt__install_recommends: false
apt__install_suggests: false
apt__configuration:
- name: seccomp
filename: 01-seccomp.conf
comment: Enable seccomp sanboxing
raw: |
APT::Sandbox::Seccomp "true";
state: present
apt__repositories:
- repo: deb https://deb.debian.org/debian {{ ansible_distribution_release }} main contrib non-free
state: absent
- repo: deb https://deb.debian.org/debian {{ ansible_distribution_release }} main contrib non-free non-free-firmware
state: absent
- repo: deb https://deb.debian.org/debian {{ ansible_distribution_release }}-updates main contrib non-free
state: absent
- repo: deb https://deb.debian.org/debian {{ ansible_distribution_release }}-updates main contrib non-free non-free-firmware
state: absent
- repo: deb https://deb.debian.org/debian {{ ansible_distribution_release }}-backports main contrib non-free
state: absent
- repo: deb https://deb.debian.org/debian {{ ansible_distribution_release }}-backports main contrib non-free non-free-firmware
state: absent
- repo: deb https://security.debian.org/debian-security {{ ansible_distribution_release }} main contrib non-free
state: absent
- repo: deb https://security.debian.org/debian-security {{ ansible_distribution_release }} main contrib non-free non-free-firmware
state: absent
- repo: deb https://security.debian.org/debian-security {{ ansible_distribution_release }}-updates main contrib non-free
state: absent
- repo: deb https://security.debian.org/debian-security {{ ansible_distribution_release }}-updates main contrib non-free non-free-firmware
state: absent
- repo: deb https://security.debian.org/debian-security {{ ansible_distribution_release }}-backports main contrib non-free
state: absent
- repo: deb https://security.debian.org/debian-security {{ ansible_distribution_release }}-backports main contrib non-free non-free-firmware
state: absent
- repo: deb http://deb.debian.org/debian {{ ansible_distribution_release }} main contrib non-free
state: absent
- repo: deb http://deb.debian.org/debian {{ ansible_distribution_release }}-updates main contrib non-free
state: absent
- repo: deb http://deb.debian.org/debian {{ ansible_distribution_release }}-backports main contrib non-free
state: absent
- repo: deb http://security.debian.org/debian-security {{ ansible_distribution_release }} main contrib non-free
state: absent
- repo: deb http://security.debian.org/debian-security {{ ansible_distribution_release }}-updates main contrib non-free
state: absent
- repo: deb http://security.debian.org/debian-security {{ ansible_distribution_release }}-backports main contrib non-free
state: absent
apt__default_sources:
- uri: tor+http://2s4yqjx5ul6okpp3f2gaunr2syex5jgbfpfvhxxbbjwnrsvbk5v3qbid.onion/debian
comment: '{{ "Official " + apt__distribution + " repositories" }}'
distribution: Debian
state: present
apt__security_sources:
- uri: tor+http://5ajw6aqf3ep7sijnscdzw77t7xq4xjpsy335yb2wiwgouo7yfxtjlmid.onion/debian-security
comment: Debian Security repository
type: "{{ apt__source_types }}"
suite: '{{ ansible_distribution_release + "-security" }}'
components: "{{ apt__distribution_components }}"
distribution: Debian
state: present
apt__nonfree: true
apparmor__mail_to: false
sysctl__parameters:
- name: virtual_memory
comment: https://wiki.archlinux.org/index.php/Sysctl#Virtual_memory
options:
- vm.dirty_ratio: 3
- vm.dirty_background_ratio: 2
- vm.swappiness: 5
- vm.vfs_cache_pressure: 50
- name: inotify
options:
- fs.inotify.max_user_watches: 4194304
- fs.inotify.max_user_instances: 8192
- name: net
options:
- net.core.netdev_max_backlog: 16384
- net.core.somaxconn: 8192
- net.ipv4.tcp_fastopen: 3
python__v3: true
python__v2: false
python__packages3:
- python3-dev
- python-is-python3
- python3-pip
- python3-setuptools
locales__list:
- ru_RU.UTF-8
- en_DK.UTF-8
locales__packages:
- localepurge
- mythes-en-us
- mythes-ru
- hunspell-en-us
- hunspell-ru
- myspell-ru
- hyphen-en-us
- hyphen-ru
- irussian
- iamerican
- iamerican-large
- aspell-ru
- enchant-2
locales__system_lang: en_US.UTF-8
kmod__load:
- name: tun
kmod__modules:
# https://github.com/GrapheneOS/infrastructure/blob/main/modprobe.d/local.conf
- name: cdrom
state: blacklist
- name: floppy
state: blacklist
- name: intel_agp
state: blacklist
- name: ip_tables
state: blacklist
- name: pcspkr
state: blacklist
- name: snd_intel8x0
state: blacklist
- name: sr_mod
state: blacklist
- name: tls
state: blacklist
- name: virtio_balloon
state: blacklist
- name: virtio_console
state: blacklist
grub__timeout_hardware: 1
grub__timeout_virtual: 1
grub__configuration:
- name: cmdline_linux_default
value:
# silent boot
# https://wiki.archlinux.org/index.php/Silent_boot
- quiet
- loglevel=3
- rd.systemd.show_status=auto
- rd.udev.log_level=3
- vt.global_cursor_default=0
- debugfs=on
# zswap
- zswap.enabled=1
- zswap.compressor=zstd
- zswap.max_pool_percent=15
# apparmor
- apparmor=1
- security=apparmor
# disable watchdog
- nowatchdog
- modprobe.blacklist=iTCO_wdt
- modprobe.blacklist=iTCO_vendor_support
- nmi_watchdog=0
# disable sss
- libahci.ignore_sss=1
# required by oomd
- swapaccount=1
- systemd.unified_cgroup_hierarchy=1
# https://kspp.github.io/Recommended_Settings#kernel-command-line-options
- randomize_kstack_offset=on
- init_on_alloc=1
- init_on_free=1
- hardened_usercopy=1
- page_alloc.shuffle=1
- slab_nomerge
- pti=on
- iommu=force
- iommu.passthrough=0
- iommu.strict=1
- mitigations=auto,nosmt
- kfence.sample_interval=100
- vsyscall=none
- vdso32=0
# - cfi=kcfi
# https://github.com/Kicksecure/security-misc/blob/master/etc/default/grub.d/40_kernel_hardening.cfg
- random.trust_bootloader=off
- random.trust_cpu=off
- extra_latent_entropy