This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlinux_mint.yaml
1029 lines (1025 loc) · 31.9 KB
/
linux_mint.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
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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Prepares LinuxMint 21.x desktop.
# start from preparing ssh:
# sudo apt install openssh-server ntp;systemctl enable ssh && systemctl start ssh
# kind: playbook
- name: prepare_mint_desktop
hosts: all
vars:
install_optional: true # should optional packages be installed?
install_deb: true # should extra deb packages should be installed
install_flatpak: true # should we install flatpak software
remove_flatpak: true # should we remove flatpak software
install_vscode_extensions: true # should we install extra vscode extensions
install_steampipe_plugins: true # install steampipe plugins (steampipe must be installed)
install_npm: true # should we install npm packages
install_zsh: true # install and configure oh-my-zhs and power10k
install_yubico: false # install yubico related software
install_state: latest # if set to latest, every pass of playbook will also update packages
config_ansible: true # do changes in change ansible.cfg
config_dconf: true # do changes in dconf editor
config_sysctl: true # do changes in sysctl
config_autostart: true # copy apps from `files/apps` to autostart
active_user: "{{ ansible_ssh_user }}" # user for which you're setting folders. By default taken from group_vars
retries_count: 1 # how many retries
delay_time: 1 # delay time in seconds between retries
bin_path: /usr/local/bin # Where to put all downloaded execs.
reboot_required: false # force reboot even if apt upgrade won't change anything
unpack_folder: /tmp/linux_mint # folder to which we're going to unpack and download files
become: true
gather_facts: false
pre_tasks:
# ansible version
- name: verify_ansible_meets_version_requirements
ansible.builtin.assert:
that: "ansible_version.full is version('2.10', '>=')"
msg: >
"You must update Ansible to at least 2.10 to use this version of playbook"
tags:
- assert
# setup module - we need these facts
- name: run_initial_setup_instead_of_gather_facts
ansible.builtin.setup:
gather_timeout: 60
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_setup_status
until: r_setup_status is success
tags:
- assert
# free space for stuff
- name: assert_root_partition_is_10_GB_of_free_space
ansible.builtin.assert: { that: item.size_available > 1073741824 } # 10 GB free
loop: '{{ ansible_mounts }}'
ignore_errors: false
when: item.mount == '/'
tags:
- assert
# check that ansible_ssh_user have been defined
- name: assert_active_user_have_been_defined_and_has_value
ansible.builtin.assert:
that: active_user is defined and active_user | length >0
msg: >
"Specify user in group_vars or passed in variable active_user"
tags:
- assert
- name: assert_supported distribution
ansible.builtin.assert:
that: ansible_distribution_major_version is version('20', '>=')
msg: >
"Not supported distrubution found: {{ ansible_distribution_major_version }}"
tags:
- assert
# load playbook variables
- name: load_playbook_vars_depending_on_distribution
ansible.builtin.include_vars:
dir: .
files_matching: "mint{{ ansible_distribution_major_version }}.*.yaml"
any_errors_fatal: true
ignore_errors: false
register: r_load_vars
until: r_load_vars is success
changed_when: false
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
failed_when: r_load_vars is failed or r_load_vars.ansible_included_var_files is not defined
tags:
- assert
tasks:
- name: display_basic_information
ansible.builtin.debug:
msg:
- "Linux Mint major version : {{ ansible_distribution_major_version }}"
- "Linux Mint version : {{ ansible_distribution_version }}"
- "Linux Mint release codename : {{ ansible_distribution_release }}"
- "Ansible version : {{ ansible_version.full }}"
- "Install optional packages : {{ install_optional | bool | lower }}"
- "Install deb packages : {{ install_deb | bool | lower }}"
- "Install_flatpak packages : {{ install_flatpak | bool | lower }}"
- "Install_npm packages : {{ install_npm | bool | lower }}"
- "Install vscode extensions : {{ install_vscode_extensions | bool | lower }} "
- "Install steampipe plugins : {{ install_steampipe_plugins | bool | lower }} "
- "Install zsh : {{ install_zsh | bool | lower }}"
- "Install Yubico : {{ install_yubico | bool | lower }}"
- "Config for Ansible : {{ config_ansible | bool | lower }}"
- "Config dconf : {{ config_dconf | bool | lower }}"
- "Config sysctl : {{ config_sysctl | bool | lower }}"
- "Config autostart : {{ config_autostart | bool | lower }}"
- "Bin Path to put files into : {{ bin_path }}"
- "Active user : {{ active_user | string }}"
- name: wait_10_seconds
ansible.builtin.pause:
seconds: 10
prompt: "Check variables - last chance to abort in 10 seconds"
# we need proper time to refresh repositories
- name: make_sure_timesyncd_is_installed
ansible.builtin.apt:
name: systemd-timesyncd
state: present
update_cache: no
allow_unauthenticated: true #workaround for expired keys
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_systemd_timesyncd
until: r_systemd_timesyncd is success
when: ansible_distribution_major_version | int > 19
any_errors_fatal: true
tags:
- packages
- base
- name: start_timesyncd_service
ansible.builtin.systemd:
name: systemd-timesyncd
state: started
enabled: true
changed_when: false
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_start_timesyncd
until: r_start_timesyncd is success
tags:
- base
- name: start_timedatectl_set_ntp
ansible.builtin.shell: timedatectl set-ntp on
tags:
- base
changed_when: false
# remove obsolete repositories
- name: remove_obsolete_repositories_from_variables_file
ansible.builtin.apt_repository:
repo: "{{ item.repo }}"
state: absent
update_cache: false
loop: "{{ repositories_remove }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_repositories_remove
until: r_repositories_remove is success
any_errors_fatal: false
tags:
- repositories
- base
- obsolete
# remove obsolete files
- name: Tasks - remove repository files
ansible.builtin.include_tasks: ./tasks/remove_repository_files.yml
args:
apply:
tags:
- repositories
- files
- remove
- base
- obsolete
tags:
- always
# remove obsolete files from 'bin_path'
- name: Remove_obsolete_files_bin_path_from_variables_file
ansible.builtin.file:
path: "{{ bin_path }}/{{ item.name }}"
state: absent
loop: "{{ files_remove_bin_path }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_files_remove_bin_path
until: r_files_remove_bin_path is success
any_errors_fatal: false
ignore_errors: true
tags:
- files
- base
- obsolete
- bin_path
# remove obsolete keys
- name: remove_obsolete_apt_keys
ansible.builtin.apt_key:
id: "{{ item }}"
state: absent
loop: "{{ keys_remove }}"
register: r_remove_keys
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_remove_keys is success
any_errors_fatal: false
tags:
- keys
- base
- obsolete
become: true
# remove obsolete packages
- name: remove_obsolete_apt_packages
ansible.builtin.apt:
name: "{{ item }}"
state: absent
loop: "{{ packages_remove }}"
register: r_remove_packages
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_remove_packages is success
when: packages_remove is defined
any_errors_fatal: false
ignore_errors: true
tags:
- packages
- base
- obsolete
# remove absolete flatpak apps, from playbooks and custom variables
- name: Remove_flatpak_apps
ansible.builtin.include_tasks: ./tasks/remove_flatpak_packages.yml
args:
apply:
tags:
- packages
- flatpak
- remove
tags:
- always
# refresh apt cache
- name: apt_initial_refresh
ansible.builtin.apt:
update_cache: yes
force: true
ignore_errors: true
any_errors_fatal: false
changed_when: false
register: r_apt_initial_refresh
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_apt_initial_refresh is success
tags:
- packages
- base
# install base apt files in case of clean system
- name: install_packages_in_case_of_clean_system
ansible.builtin.apt:
name: "{{ item }}"
state: latest
loop: "{{ packages_clean_system }}"
register: r_clean_system_packages
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_clean_system_packages is success
any_errors_fatal: false
tags:
- packages
- base
- clean_system
# Install apt pgp keys (files)
- name: install_apt_keys
ansible.builtin.apt_key:
url: "{{ item }}"
state: present
loop: "{{ keys }}"
register: r_keys
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_keys is success
any_errors_fatal: true
tags:
- keys
- base
# Install apt pgp keys (keyserver)
- name: install_apt_keys_keyserver
ansible.builtin.apt_key:
keyserver: "{{ item.keyserver }}"
state: present
id: "{{ item.id }}"
loop: "{{ keys_keyserver }}"
register: r_keys_keyserver
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_keys_keyserver is success
any_errors_fatal: true
tags:
- keys
- base
- name: install_custom_apt_keys
ansible.builtin.apt_key:
url: "{{ item }}"
state: present
loop: "{{ custom_keys | default([]) }}"
register: r_custom_keys
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_custom_keys is success
when: custom_keys is defined
any_errors_fatal: true
tags:
- keys
- base
- custom
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/deb822_repository_module.html
- name: Add_basic_repositories_as_deb822_repository
ansible.builtin.deb822_repository:
name: "{{ item.name }}"
types: "{{ item.types | default('deb') }}"
suites: "{{ item.suites | default('/') }}"
components: "{{ item.components | default(' ') }}"
uris: "{{ item.uris }}"
enabled: "{{ item.enabled | default('true') }}"
signed_by: "{{ item.signed_by | default('null') }}"
architectures: "{{ item.architectures | default('') }}"
loop: "{{ deb822_repositories }}"
register: r_repositories
until: r_repositories is success
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
tags:
- repositories
- base
- deb822
- name: Add_custom_repositories_as_deb822_repository
ansible.builtin.deb822_repository:
name: "{{ item.name }}"
types: "{{ item.types | default('deb') }}"
suites: "{{ item.suites | default('/') }}"
components: "{{ item.components | default(' ') }}"
uris: "{{ item.uris }}"
enabled: "{{ item.enabled | default('true') }}"
signed_by: "{{ item.signed_by | default('null') }}"
architectures: "{{ item.architectures | default('') }}"
register: r_custom_repositories
until: r_custom_repositories is success
loop: "{{ custom_repositories }}"
when: custom_repositories is defined and custom_repositories | length > 0
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
tags:
- repositories
- base
- deb822
- custom
- name: Add_optional_repositories_as_deb822_repository
ansible.builtin.deb822_repository:
name: "{{ item.name }}"
types: "{{ item.types | default('deb') }}"
suites: "{{ item.suites | default('/') }}"
components: "{{ item.components | default(' ') }}"
uris: "{{ item.uris }}"
enabled: "{{ item.enabled | default('true') }}"
signed_by: "{{ item.signed_by | default('null') }}"
architectures: "{{ item.architectures | default('') }}"
loop: "{{ deb822_repositories_optional }}"
register: r_optional_repositories
until: r_optional_repositories is success
when: deb822_repositories_optional is defined and deb822_repositories_optional | length > 0
tags:
- repositories
- base
- deb822
# restart apt cache
- name: apt_after_repos_refresh
ansible.builtin.apt:
update_cache: yes
force: true
ignore_errors: true
any_errors_fatal: false
changed_when: false
register: r_apt_after_repos_refresh
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_apt_after_repos_refresh is success
tags:
- packages
- base
# make sure all dpkg are already configured
- name: reconfigure_all_waiting_packages
ansible.builtin.shell: dpkg --configure -a
any_errors_fatal: false
register: r_reconfigure_all_waiting_packages
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_reconfigure_all_waiting_packages is success
failed_when: false
changed_when: false
tags:
- packages
- base
# clean cache in case of initial apt failure
- name: apt_clean
ansible.builtin.shell: apt clean all -y
any_errors_fatal: false
register: r_apt_clean
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_apt_clean is success
when: r_apt_initial_refresh.failed
changed_when: r_apt_clean.rc != 0
tags:
- packages
- base
# Install essentials - packages needed for repos or other packages. Mostly OS-related
- name: install_essential_packages
ansible.builtin.apt:
name: "{{ item }}"
state: "{{ install_state }}"
update_cache: no
loop: "{{ packages_essential }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: packages_essential
until: packages_essential is success
any_errors_fatal: false
async: 6000
poll: 30
tags:
- packages
- base
# Install basic packages
- name: install_packages
ansible.builtin.apt:
name: "{{ item }}"
state: "{{ install_state }}"
update_cache: no
loop: "{{ packages }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_packages
until: r_packages is success
any_errors_fatal: false
async: 6000
poll: 30
tags:
- packages
- base
- name: install_custom_packages
ansible.builtin.apt:
name: "{{ item }}"
state: "{{ install_state }}"
update_cache: no
loop: "{{ custom_packages | default([]) }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_custom_packages
until: r_custom_packages is success
any_errors_fatal: false
async: 6000
poll: 30
tags:
- packages
- base
- custom
# Install flatpak packages
- name: install_flatpak_apps
community.general.flatpak:
name: "{{ item.name | string }}"
state: present
method: system
loop: "{{ flatpak }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_install_flatpak
until: r_install_flatpak is success
any_errors_fatal: false
when: install_flatpak is defined and install_flatpak
tags:
- packages
- flatpak
# Upgrade flatpak apps
- name: upgrade_flatpak_apps
ansible.builtin.command: flatpak update -y
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_update_flatpak
until: r_update_flatpak is success
changed_when: r_update_flatpak.rc != 0
ignore_errors: true
when: install_flatpak is defined and install_flatpak
tags:
- packages
- flatpak
# Install optional packages - if variable `install_optional` is set to true
- name: install_optional_packages
ansible.builtin.apt:
name: "{{ item }}"
state: "{{ install_state }}"
update_cache: no
loop: "{{ packages_optional }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: packages_optional
until: packages_optional is success
when: install_optional
any_errors_fatal: false
tags:
- packages
- optional
# Install 3-rd party software not available in repos
- name: install_extra_deb_packages_from_variables_file
ansible.builtin.apt:
deb: "{{ item }}"
state: present
update_cache: no
only_upgrade: yes
loop: "{{ deb }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_apt_deb
until: r_apt_deb is success
any_errors_fatal: false
ignore_errors: true
when: install_deb
tags:
- packages
- deb
- name: install_and_upgrade_pip_packages
ansible.builtin.pip:
name: "{{ item }}"
extra_args: --upgrade --upgrade-strategy=only-if-needed --ignore-installed
executable: "{{ pip_executable }}"
loop: "{{ pip }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_pip
until: r_pip is success
any_errors_fatal: false
ignore_errors: true
when: pip_executable is defined
tags:
- packages
- base
- python
- name: install_npm_packages
community.general.npm:
name: "{{ item.name | string }}"
state: "{{ item.state | string }}"
global: yes
loop: "{{ npm }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_install_npm
until: r_install_npm is success
any_errors_fatal: false
when: install_npm
tags:
- packages
- npm
# Download 3-rd party software and unarchive it to `bin_path` setting +x
- name: check_if_bin_path_exists
ansible.builtin.file:
path: "{{ bin_path }}"
state: directory
mode: 0755
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
tags:
- base
- downloads
- apps
- name: download_and_unarchive
ansible.builtin.unarchive:
src: "{{ item.url }}"
dest: "{{ bin_path }}"
keep_newer: true
list_files: yes
mode: +x
remote_src: yes
exclude:
- LICENSE
- README.md
- CHANGELOG.md
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_unarchive
until: r_unarchive is success
failed_when: r_unarchive.files is not defined or r_unarchive.files | reject("equalto", "") | list | length == 0
loop: "{{ downloads }}"
tags:
- base
- downloads
- apps
# Download 3-rd party software and unarchive it (flatten archive folder tree) to `bin_path` setting +x
- name: download_unarchive_flatten
ansible.builtin.include_tasks: ./tasks/download_files.yml
loop: "{{ unpack }}"
args:
apply:
tags:
- downloads
- apps
- tasks
tags:
- always
# Download 3-rd party software to `bin_path` setting +x
- name: download_regular_files
ansible.builtin.get_url:
url: "{{ item.url }}"
dest: "{{ bin_path }}/{{ item.destination }}"
mode: 0755
force: yes
loop: "{{ files }}"
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
register: r_download_files
until: r_download_files is success
tags:
- base
- downloads
- apps
- name: put_desktop_files_for_applications
ansible.builtin.copy:
dest: /usr/share/applications
src: "{{ item.desktop_file }}"
owner: root
group: root
mode: 0644
loop: "{{ files }}"
when: item.desktop_file is defined and item.desktop_file | length > 0
any_errors_fatal: false
register: r_put_desktop_files
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_put_desktop_files is success
tags:
- base
- downloads
- apps
- name: refresh_desktop_database
ansible.builtin.shell: update-desktop-database
register: r_refresh_desktop_database
until: r_refresh_desktop_database is success
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
failed_when: r_refresh_desktop_database.rc != 0
ignore_errors: true
changed_when: false
tags:
- base
- downloads
- apps
# Start user-related modification block
- name: user_modifications_block
tags:
- base
- user
- zsh
block:
- name: create_or_check_users_groups
ansible.builtin.user:
name: "{{ active_user }}"
groups:
- root
- vboxusers
- docker
- adm
- sudo
- video
- cdrom
- plugdev
- dialout
state: present
append: true
any_errors_fatal: false
register: r_active_user_account
until: r_active_user_account is success
tags:
- base
- user
- name: fact_for_user_home_dir
ansible.builtin.set_fact:
"active_user_homedir": "{{ r_active_user_account.home }}"
tags:
- base
- user
- name: make_sure_autostart_folder_exists
ansible.builtin.file:
path: "{{ active_user_homedir }}/.config/autostart"
state: directory
owner: "{{ active_user }}"
group: "{{ active_user }}"
mode: 0755
register: r_create_autostart
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_create_autostart is success
any_errors_fatal: true
tags:
- base
- user
- name: create_startup_applications
ansible.builtin.copy:
dest: "{{ active_user_homedir }}/.config/autostart/{{ item.filename }}"
src: "{{ item.source }}"
owner: "{{ active_user }}"
group: "{{ active_user }}"
mode: 0644
force: false
loop: "{{ startup }}"
any_errors_fatal: false
register: r_create_startup_applications
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_create_startup_applications is success
when: config_autostart is defined and config_autostart
- name: configure_zsh
ansible.builtin.include_tasks: ./tasks/configure_zsh.yml
when: install_zsh is defined and install_zsh
tags:
- base
- user
- zsh
- name: install_yubico
ansible.builtin.include_tasks: ./tasks/install_yubico_software.yml
when: install_yubico is defined and install_yubico
tags:
- base
- user
- yubico
- name: start ansible block
tags:
- ansible
when: config_ansible
block:
- name: check_if_ansible_cfg_exists
ansible.builtin.stat:
path: "{{ ansible.cfg }}"
register: r_check_if_ansible_cfg_exists
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_check_if_ansible_cfg_exists is success
- name: fact_if_ansible_cfg_exists
ansible.builtin.set_fact:
ansible_exists: "{{ r_check_if_ansible_cfg_exists.stat.exists }}"
when: r_check_if_ansible_cfg_exists is success
- name: change_ansible_options
community.general.ini_file:
path: /etc/ansible/ansible.cfg
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value | string }}"
state: "{{ item.state | string }}"
mode: 0644
backup: yes
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
loop: "{{ ansible.config }}"
register: r_change_ansible_options
until: r_change_ansible_options is success
when: ansible_exists
# start steampipe plugins block
- name: install_steampipe_plugins_block
block:
- name: check_if_steampipe_exists
ansible.builtin.package_facts:
manager: auto
strategy: all
register: r_check_if_steampipe_exists
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_check_if_steampipe_exists is success
any_errors_fatal: true
ignore_errors: false
- name: install_steampipe_plugins
ansible.builtin.include_tasks: ./tasks/steampipe_plugins.yml
loop: "{{ steampipe.plugins }}"
when: "'steampipe' in ansible_facts.packages and install_steampipe_plugins"
args:
apply:
tags:
- steampipe
- plugins
- apps
- tasks
tags:
- always
- name: update_steampipe_plugins
ansible.builtin.shell:
cmd: "set -o pipefail|steampipe plugin update --all"
register: r_install_steampipe_plugins
become: true
become_user: "{{ active_user }}"
any_errors_fatal: true
failed_when: r_install_steampipe_plugins.rc != 0 and r_install_steampipe_plugins.stderr != ""
changed_when: false
when: "steampipe.update_plugins"
# start vscode extensions block
- name: install_vscode_extensions
tags:
- optional
- user
- vscode
- eztensions
when: install_vscode_extensions
block:
- name: remove_obsolete_extensions
ansible.builtin.shell: "code --uninstall-extension {{ item }} | true"
any_errors_fatal: false
ignore_errors: true
loop: "{{ vscode_obsolete }}"
become: true
become_user: "{{ active_user }}"
register: r_remove_obsolete_extensions
changed_when: "'was successfully uninstalled!' in r_remove_obsolete_extensions.stdout"
- name: run_dpkg_query_for_installed_extensions
ansible.builtin.shell: dpkg-query -s code | grep 'install ok installed'
register: r_dpkg_query_vscode
any_errors_fatal: false
ignore_errors: true
changed_when: "r_dpkg_query_vscode.stdout != 'Status: install ok installed'"
become: true
become_user: "{{ active_user }}"
- name: install_missing_extensions
ansible.builtin.shell: if [ ! $(code --list-extensions | grep {{ item }}) ]; then code --install-extension {{ item }} --force; fi
loop: "{{ vscode }}"
register: r_install_extension
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_install_extension is success
become: true
become_user: "{{ active_user }}"
changed_when: r_install_extension.stdout | length > 0
when: r_dpkg_query_vscode.rc == 0
any_errors_fatal: false
ignore_errors: true
# Start OS related block
- name: start_os_tweaks
tags:
- user
- base
block:
# OS related tweaks and finetuning
- name: set_timezone
community.general.timezone:
name: "{{ timezone }}"
any_errors_fatal: false
# Neofetch block
- name: Gather the package facts
ansible.builtin.package_facts:
manager: auto
register: r_package_facts
until: r_package_facts is success
changed_when: false
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
tags:
- base
- neofetch
failed_when: false
- name: Run neofetch external task from 'tasks'
ansible.builtin.include_tasks: ./tasks/configure_neofetch.yml
args:
apply:
tags:
- base
- neofetch
vars:
ansible_become: yes
ansible_become_user: "{{ active_user }}"
tags:
- always
when: "'neofetch' in r_package_facts.ansible_facts.packages"
# End of Neofetch block
# Timeshift block
- name: enable_timeshift_in_rsync_mode
ansible.builtin.shell: timeshift --rsync --yes
args:
creates: /etc/timeshift.json
any_errors_fatal: false
# Sudoers
- name: add_user_to_sudoers
ansible.builtin.copy:
dest: "/etc/sudoers.d/{{ active_user }}"
owner: root
group: root
mode: 0444
content: |
{{ active_user }} ALL=(ALL) NOPASSWD: ALL
any_errors_fatal: false
retries: "{{ retries_count }}"
- name: create_fstrim_folder_for_systemd_override
ansible.builtin.file:
path: /etc/systemd/system/fstrim.timer.d
state: directory
mode: 0644
- name: create_fstrim_override_for_systemd
ansible.builtin.copy:
dest: /etc/systemd/system/fstrim.timer.d/override.conf
content: |
[Timer]
OnCalendar=hourly
OnBootSec=5m
mode: 0755
register: r_create_fstrim_override
- name: start_fstrim.timer
ansible.builtin.systemd:
daemon_reload: true
name: fstrim.timer
state: restarted
enabled: true
when: r_create_fstrim_override.changed
- name: sysctl_changes
ansible.posix.sysctl:
name: "{{ item.name | string }}"
value: "{{ item.value | string }}"
state: "{{ item.state | string }}"
reload: yes
loop: "{{ sysctl }}"
register: r_sysctl_changes
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_sysctl_changes is success
when: config_sysctl
- name: change_alternatives
community.general.alternatives:
name: "{{ item.name }}"
path: "{{ item.path }}"
loop: "{{ alternatives }}"
register: r_alternatives
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_alternatives is success
- name: set_EDITOR_variable
ansible.builtin.lineinfile:
dest: "/etc/environment"
state: present
regexp: "^{{ item.name }}"
line: "{{ item.name }}={{ item.value }}"
loop: "{{ global_env }}"
register: r_environment
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_environment is success
- name: reset_dconf_values
community.general.dconf:
key: "{{ item.key }}"
state: "{{ item.state }}"
loop: "{{ dconf }}"
register: r_dconf_values
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_dconf_values is success
when: config_dconf and "absent" in item.state
any_errors_fatal: false
ignore_errors: true
become: true
become_user: "{{ active_user }}"
tags:
- dconf
- name: set_dconf_values
community.general.dconf:
key: "{{ item.key }}"
state: "{{ item.state }}"
value: "{{ item.value | string }}"
loop: "{{ dconf }}"
register: r_dconf_values
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: r_dconf_values is success
when: config_dconf and "present" in item.state
become: true
become_user: "{{ active_user }}"
tags:
- dconf
# remove obsoleted `list` files left by new packages
- name: Tasks - remove repository files
ansible.builtin.include_tasks: ./tasks/remove_repository_files.yml
args:
apply:
tags:
- repositories
- files
- remove
- base
- obsolete
tags:
- always
- name: update_all_packages
ansible.builtin.apt:
upgrade: "yes"
update_cache: yes
autoclean: yes
register: apt_upgrade
retries: "{{ retries_count }}"
delay: "{{ delay_time }}"
until: apt_upgrade is success
async: 6000
poll: 30
tags: