-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver-nozfs.yaml
360 lines (322 loc) · 9.23 KB
/
server-nozfs.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
# ====================================================
# Basic server setup
# ====================================================
---
- hosts: localhost
become: false
gather_facts: true
user: "{{lookup('env', 'USER')}}"
vars:
home: "{{ansible_user_dir}}"
codename: "{{ansible_distribution_release}}"
vars_prompt:
- name: arch
prompt: "Select hardware architecture (arm64/amd64):"
default: "amd64"
private: false
tasks:
- name: Confirm variable facts are populated and accurate
ansible.builtin.debug:
msg:
- "$HOME is set to {{ home }}"
- "User is {{ansible_user}}"
- "Codename is {{codename}}"
- "Architecture is {{arch}}"
- name: varcheck
pause:
prompt: "Check variables above. Hit return to continue. Have you added ssh keys?"
- name: add contrib and non-free repos
command: sed -i '/^\([^#].*main\)*$/s/main/& contrib non-free non-free-firmware/' /etc/apt/sources.list
become: true
- name: Create .config dir
file:
path: "{{home}}/.config"
state: directory
- name: Create zsh config dir
file:
path: "{{home}}/.config/zsh"
state: directory
- name: Create nvim config dir
file:
path: "{{home}}/.config/nvim"
state: directory
- name: install essential packages
apt:
name:
- git
- software-properties-common
- python3-pip
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
update_cache: true
become: true
- name: Install docker gpg key
command: wget -qO- https://download.docker.com/linux/debian/gpg | tee /etc/apt/trusted.gpg.d/docker.asc
become: true
- name: Install key for influxdata
command: wget -qO- https://repos.influxdata.com/influxdb.key | tee /etc/apt/trusted.gpg.d/influx.asc
become: true
- name: install docker repo
apt_repository:
repo: "deb [arch={{arch}}] https://download.docker.com/linux/debian {{codename}} stable"
state: present
become: true
- name: install influxDB repo
apt_repository:
repo: "deb https://repos.influxdata.com/debian {{codename}} stable"
state: present
become: true
- name: Remove old docker
apt:
name:
- docker
- docker-engine
- docker.io
- containerd
- runc
- docker-ce
- docker-ce-cli
- containerd.io
state: absent
update_cache: true
autoremove: yes
become: true
- name: Install docker
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
update_cache: true
register: apt_status
until: apt_status is success
retries: 2
delay: 5
become: true
- name: install all packages
apt:
name:
- docker-compose
- zoxide
- rclone
- appstream
- attr
- kmod
- autoconf
- automake
- autopoint
- nfs-common
- autotools-dev
- bind9-host
- cgroupfs-mount
- cmdtest
- crda
- discover
- discover-data
- dns-root-data
- dnsutils
- doc-debian
- emacsen-common
- exfat-fuse
- exfat-utils
- fd-find
- ffmpeg
- fontconfig
- fonts-dejavu-core
- gdisk
- hdparm
- iw
- keyboard-configuration
- laptop-detect
- locales
- lsof
- lz4
- m4
- mailutils
- mailutils-common
- make
- man-db
- mariadb-common
- mdadm
- modemmanager
- mokutil
- mysql-common
- neovim
- netcat-traditional
- nmap
- nmap-common
- os-prober
- pciutils
- picocom
- pkg-config
- plocate
- powermgmt-base
- ppp
- protobuf-compiler
- psmisc
- python3
- reportbug
- ripgrep
- rsync
- runit-helper
- screen
- shim-signed-common
- shim-unsigned
- smartmontools
- tdb-tools
- tini
- tmux
- traceroute
- udisks2
- unzip
- wireless-regdb
- x11-common
- xclip
- xkb-data
- zsh
- zsh-common
- g++
- libncurses-dev
- fzf
- exa
- libssl-dev
- yamllint
- spl
- lm-sensors
- exa
- bat
- duf
- mosh
state: latest
update_cache: true
become: true
- name: Installing oh-my-zsh
shell: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended
- name: Install powerlevel10k theme
git:
repo: https://github.com/romkatv/powerlevel10k.git
dest: "{{home}}/.oh-my-zsh/custom/themes/powerlevel10k"
depth: 1
- name: Add github identity
copy:
dest: "{{home}}/.gitconfig"
content: |
[user]
name = mcondren
email = [email protected]
- name: Export zsh DOTFILE location system-wide
lineinfile: dest=/etc/zsh/zshenv
regexp="^export"
line="export ZDOTDIR=$HOME/.config/zsh"
state=present
become: true
- name: add prems for telegraf to sudoers
lineinfile:
dest: /etc/sudoers
state: present
line: '{{ item }}'
with_items:
- '# For smartctl add the following lines:'
- 'Cmnd_Alias SMARTCTL = /usr/sbin/smartctl'
- 'telegraf ALL=(ALL) NOPASSWD: SMARTCTL'
- 'Defaults!SMARTCTL !logfile, !syslog, !pam_session'
- name: Create ramdisk in fstab
lineinfile: dest=/etc/fstab
line="ramdisk /tmp/cache tmpfs defaults,size=1G,x-gvfs-show 0 0"
state=present
become: true
- name: mount NAS nfs drive
lineinfile: dest=/etc/fstab
line='coldstorage.ansible.house:/mnt/ColdStorage/backup /backup nfs4 defaults 0 0'
state=present
- name: Copy .zshenv to $HOME
copy:
src: "/etc/zsh/zshenv"
dest: "{{home}}/.zshenv"
group: "{{ansible_user_id}}"
owner: "{{ansible_user_id}}"
become: true
- name: Adding github key
shell: |
eval `ssh-agent -s`
ssh-add $HOME/.ssh/github
ssh-add $HOME/.ssh/id_rsa
- name: Clone dotfiles repo
git:
repo: [email protected]:mcondren/dotfiles.git
version: master
dest: "{{home}}/dotfiles"
key_file: "{{home}}/.ssh/github"
accept_hostkey: true
# ssh-agent doesn't allow key to pass through remote sudo commands.
become: false
- name: Create a symbolic links for dotfiles (.zshrc)
ansible.builtin.file:
src: "{{home}}/dotfiles/.zshrc"
dest: "{{home}}/.config/zsh/.zshrc"
state: link
- name: Create a symbolic links for dotfiles (nvim.init)
ansible.builtin.file:
src: "{{home}}/dotfiles/init.vim"
dest: "{{home}}/.config/nvim/init.vim"
state: link
- name: Create a symbolic links for dotfiles (.p10k.zsh)
ansible.builtin.file:
src: "{{home}}/dotfiles/.p10k.zsh"
dest: "{{home}}/.config/zsh/.p10k.zsh"
state: link
- name: Clone docker repo
git:
repo: [email protected]:mcondren/docker.git
version: master
dest: "{{home}}/docker"
key_file: "{{home}}/.ssh/github"
accept_hostkey: true
# ssh-agent doesn't allow key to pass through remote sudo commands.
become: false
- name: Set Crontab env variable for rclone/rsync
cron:
name: SSH_AUTH_SOCK
env: true
job: /tmp/ssh-agent-root-cron
become: true
- name: Add weekly rclone backup job to crontab
cron:
name: "rclone backup"
special_time: weekly
job: "/usr/bin/rclone sync /backup/docker crypt:backup/docker"
become: true
- name: Upgrade all packages
apt: upgrade=safe
become: true
- name: Set shell to ZSH
user:
name: "{{ansible_user_id}}"
shell: /bin/zsh
become: true
- name: automount share
shell: 'mount -a'
- name: Upgrade the OS (apt-get dist-upgrade)
apt:
upgrade: dist
- name: create rsync config dir
file:
path: "{{home}}/.config/rclone"
state: directory
mode: '0755'
- name: Copy rclone config
copy:
src: "/backup/files/rclone.conf"
dest: "{{home}}/.config/rclone/rclone.conf"
group: "{{ansible_user_id}}"
owner: "{{ansible_user_id}}"
become: true
- name: Add telegraf config
copy:
src: "/backup/files/telegraf.conf"
dest: "/etc/telegraf/telegraf.conf"
group: "{{ansible_user_id}}"
owner: "{{ansible_user_id}}"
become: true