-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathserver-basics.yaml
127 lines (116 loc) · 4.06 KB
/
server-basics.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
---
- name: Do basic setup on the server
hosts: all
gather_facts: false
tasks:
- name: Disable sleep
# https://serverfault.com/questions/1045949/how-to-disable-suspend-on-ubuntu-20-04-systemd-via-cli
become: True
block:
- name: Change the logind service config file
blockinfile:
path: /etc/systemd/logind.conf
block: |
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
- name: Restart service
shell: systemctl restart systemd-logind
- name: Disable sleep in systemd
# https://www.unixtutorial.org/disable-sleep-on-ubuntu-server/
become: true
shell: systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
- name: Upgrade the system
become: true
apt:
update_cache: yes
upgrade: yes
- name: Ensure all basic dependencies are present
block:
- name: apt packages
become: true
apt:
pkg: "{{ item }}"
state: latest
ignore_errors: yes
loop:
- git # git
- curl # curl webpage
- vim # text editor
- python3 # python
- python3-pip # pip
- htop # for top resource usage
- iotop # for top io usage
- lm-sensors
- stress # stress tests
- vlc # media player
- jq # json parse
- net-tools # for ifconfig
- speedtest-cli # for speedtests
- w3m
- ufw #firewall
- fio # for disk tests
- mesa-utils # for GPU tests
- cpustat # for CPU logs
- xclip # for clipboard
- nethogs # for network usage
- fzf # fuzzy find, to get a list of things to select from
- intel-gpu-tools # for intel GPU usage, MIGHT NOT BE FOUND
- firefox # browser
- testdisk # life saver if your disk is a bit sus, so its a nice util to have handy
- tmux # terminal mulitplexor to mainly allow you to create a re-attachable session on the server. Google for more info on how to use
- smartmontools # to be able to use smartctl to get SMART data about storage devices
- hwinfo # hardware info
- name: Install pyyaml python package
ansible.builtin.pip:
name:
- pyyaml
- kubernetes
- name: Install kubectx/kubens
# https://github.com/ahmetb/kubectx
snap:
name: kubectx
classic: true
become: True
- name: Create directories
file:
path: "{{ item }}"
state: directory
mode: '0755'
with_items:
- "{{ dir_data }}"
- "{{ dir_repos }}"
- "{{ dir_data_movies }}"
- "{{ dir_data_shows }}"
- "{{ dir_data_games }}"
- "{{ dir_data_books }}"
- "{{ dir_data_music }}"
- "{{ dir_data_downloads }}"
- "{{ dir_home }}{{ dir_data_config_suffix }}"
- name: Setup the bashrc file and the vimrc file
block:
- name: Clone useful_files from github
include_tasks: tasks-clone-git-repo.yaml
vars:
repo_dir: "{{ useful_files_repo_dir }}"
repo_link: https://github.com/Kimi450/useful_files.git
- name: Transfer bashrc file
copy:
remote_src: True
src: "{{ useful_files_repo_dir }}/.bashrc"
dest: "{{ dir_home }}"
- name: Transfer vimrc edit script
copy:
remote_src: True
src: "{{ useful_files_repo_dir }}/vimmer.sh"
dest: "{{ dir_home }}"
mode: "0755"
- name: Run vimrc edit script
command: "{{ useful_files_repo_dir }}/vimmer.sh"
- name: Run vimrc edit script for sudo
become: true
command: "{{ useful_files_repo_dir }}/vimmer.sh"
vars:
useful_files_repo_dir: "{{ dir_repos }}/useful_files"