-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
382 lines (311 loc) · 9.54 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
# ansible-playbook main.yml -i hosts.yml -l <host>
# ansible-playbook main.yml -i hosts.yml --tags <tag1>,<tag2>
# ansible-playbook main.yml -i hosts.yml -e <variable>=<value>
# -i = inventory file
# -l = limit host
# -e = define a variable
#
# Get a list of facts:
# ansible -m setup
# ansible loki -m setup -a 'filter=ansible_architecture'
---
### ALL
- hosts:
- pve_hosts
- lxc
- vm
- vpn_gw
become: true
become_user: root
roles:
## ESSENTIALS (Update/Upgrade System, User, dotfiles, Tools, timezone, sudo)
- role: my.essentials
tags: essentials
## MSMTP (https://github.com/chriswayg/ansible-msmtp-mailer)
- role: chriswayg.msmtp-mailer
tags: msmtp
## NTP (https://github.com/geerlingguy/ansible-role-ntp)
- role: geerlingguy.ntp
tags: ntp
## UNATTENDED-UPGRADES (https://github.com/hifis-net/ansible-role-unattended-upgrades)
- role: hifis.unattended_upgrades
unattended_origins_patterns:
- 'origin=Debian,codename=${distro_codename},label=Debian-Security'
- 'o=Debian,codename=${distro_codename},label=Debian'
when:
- ansible_lsb.id == "Debian"
tags: unattended_upgrades
- role: hifis.unattended_upgrades
unattended_origins_patterns:
- 'origin=Raspbian,codename=${distro_codename},label=Raspbian'
when:
- ansible_distribution == "Debian"
- ansible_lsb.id == "Raspbian"
tags: unattended_upgrades
- role: hifis.unattended_upgrades
unattended_origins_patterns:
- 'origin=Ubuntu,archive=${distro_codename}-security'
- 'o=Ubuntu,a=${distro_codename}'
- 'o=Ubuntu,a=${distro_codename}-updates'
when:
- ansible_distribution == "Ubuntu"
tags: unattended_upgrades
####################################################
# GROUP SPECIFIC CONFIGURATIONS
####################################################
## PROXMOX: HOSTS
- hosts: pve_hosts
become: true
become_user: root
roles:
## SAMBA (https://github.com/bertvv/ansible-role-samba)
- role: bertvv.samba
tags: samba
## PROXMOX (https://github.com/lae/ansible-role-proxmox)
- role: lae.proxmox
tags: proxmox
- role: my.proxmox
tags: proxmox
## SMART (https://github.com/stuvusIT/smartd)
- role: stuvusit.smartd
smartd_devices:
/dev/nvme0n1:
temperature_report_info: 55
temperature_report_crit: 70
tags: smartd
tasks:
- name: "create bin directory"
become: true
become_user: "{{ user_username }}"
file:
path: ~/bin
state: directory
mode: 0755
tags: copy-scripts
- name: "copy scripts"
become: true
become_user: "{{ user_username }}"
copy:
src: files/hosts/pve_hosts/
dest: ~/bin/
mode: 0755
tags: copy-scripts
## PROXMOX: CT & VMs
- hosts: lxc, vm
become: true
become_user: root
roles:
## SAMBA (https://github.com/bertvv/ansible-role-samba)
- role: bertvv.samba
tags: samba
## SECURITY (https://github.com/geerlingguy/ansible-role-security)
- role: geerlingguy.security
tags: security
## VPN-GATEWAYS
- hosts: vpn_gw
become: true
become_user: root
tasks:
- name: Setup static ip address configuration
template:
src: dhcpcd.conf-static-ip.j2
dest: "/etc/dhcpcd.conf"
owner: root
group: root
mode: 0644
tags: setup-static-ip-address
- name: Create custom.list (local dns records for pihole)
template:
src: pihole/custom.list.j2
dest: "/etc/pihole/custom.list"
owner: root
group: root
mode: 0644
become: true
roles:
## pihole (https://github.com/r-pufky/ansible_pihole)
- role: r_pufky.pihole
tags: pihole
post_tasks:
- name: 'Update pihole gravity database'
ansible.builtin.command: 'pihole -g'
register: myoutput
changed_when: myoutput.rc != 0
tags: pihole
## Synology NAS
- hosts: nas
#become: true
#become_user: root
#tags:
#roles:
tasks:
- name: add SSH public keys
import_tasks: tasks/ssh_authorized_keys.yml
- name: "copy arp.sh for wakeonlan"
become: true
become_user: "{{ user_username }}"
copy:
src: files/hosts/loki/arp.sh
dest: ~/bin/
mode: 0777
tags: crontab, crontab-arp, copy-scripts
####################################################
# CLIENT SPECIFIC CONFIGURATIONS
####################################################
## pve-ct-iobroker (Ubuntu)
- hosts: pve-ct-iobroker
become: true
become_user: root
tags: pve-ct-iobroker
roles:
tasks:
- name: "create bin directory"
become: true
become_user: "{{ user_username }}"
file:
path: ~/bin
state: directory
mode: 0755
tags: copy-scripts
- name: "copy scripts"
become: true
become_user: "{{ user_username }}"
copy:
src: files/hosts/pve-ct-iobroker/
dest: ~/bin/
mode: 0755
tags: copy-scripts
- name: "create cronjob for iface metric @ reboot"
ansible.builtin.cron:
name: "iface metric"
special_time: reboot
job: "ifmetric eth0 100 && ifmetric eth1 200"
tags: crontab
### copy restart-smartmeter.sh
- name: "copy restart-smartmeter.sh"
copy:
src: files/hosts/pve-ct-iobroker/restart-smartmeter.sh
dest: ~/bin/
mode: 0755
tags: copy-scripts, smartmeter
- name: Create a symbolic for /usr/bin/restart-smartmeter.sh
ansible.builtin.file:
src: /home/darkiop/bin/restart-smartmeter.sh
dest: /usr/bin/restart-smartmeter.sh
owner: darkiop
group: darkiop
state: link
tags: copy-scripts, smartmeter
### Restart SmartMeter
- name: Restart ser2net.service @loki, socat.service @pve-ct-iobroker and smartmeter.0/1 instances @ioBroker
command: bash /usr/bin/restart-smartmeter.sh
tags: smartmeter, restart-smartmeter
### copy rsync-backups.sh
- name: "copy rsync-backups.sh"
become: true
become_user: "{{ user_username }}"
copy:
src: files/hosts/pve-ct-iobroker/rsync-backups.sh
dest: ~/bin/rsync-backups.sh
mode: 0755
tags: copy-scripts, rsync-backups
- name: "create cronjob for rsync-backups.sh"
ansible.builtin.cron:
name: "setup crontab for rsync-backups.sh"
minute: "02"
hour: "19"
job: "/home/darkiop/bin/rsync-backups.sh >/dev/null 2>&1"
tags: crontab, crontab-rsync-backups, rsync-backups
## loki (Raspbian)
- hosts: loki
become: true
become_user: root
tags: loki
roles:
tasks:
- name: Setup static ip address configuration
template:
src: dhcpcd.conf-static-ip.j2
dest: "/etc/dhcpcd.conf"
owner: root
group: root
mode: 0644
tags: setup-static-ip-address
- name: "copy ser2net.yaml to /etc/ser2net.yaml"
copy:
src: files/hosts/loki/ser2net.yaml
dest: /etc/ser2net.yaml
mode: 0644
tags: ser2net
- name: Reload service ser2net
service:
name: ser2net
state: restarted
tags: ser2net
- name: "Copy restart-smartmeter.sh to /usr/local/bin/restart-smartmeter.sh"
copy:
src: files/hosts/pve-ct-iobroker/restart-smartmeter.sh
dest: /usr/local/bin/restart-smartmeter.sh
mode: 0755
tags: smartmeter, copy-scripts
- name: Creates an entry like "@reboot /usr/local/bin/restart-smartmeter.sh"
ansible.builtin.cron:
name: "run restart-smartmeter.sh after reboot via crontable"
special_time: reboot
job: "/usr/local/bin/restart-smartmeter.sh"
tags: crontab, crontab-smartmeter, smartmeter
- name: Create a symbolic link for private nopw ssh key
ansible.builtin.file:
src: /home/darkiop/.ssh/darkiop@loki_ed25519_nopw
dest: /home/darkiop/.ssh/id_rsa
owner: darkiop
group: darkiop
state: link
tags: ssh
- name: Create a symbolic link for public nopw ssh key
ansible.builtin.file:
src: /home/darkiop/.ssh/darkiop@loki_ed25519_nopw.pub
dest: /home/darkiop/.ssh/id_rsa.pub
owner: darkiop
group: darkiop
tags: ssh
### arp cron for wakeonlan
- name: "create bin directory"
become: true
become_user: "{{ user_username }}"
file:
path: ~/bin
state: directory
mode: 0755
tags: crontab, crontab-arp, copy-scripts
- name: "copy arp.sh for wakeonlan"
become: true
become_user: "{{ user_username }}"
copy:
src: files/hosts/loki/arp.sh
dest: ~/bin/
mode: 0777
tags: crontab, crontab-arp, copy-scripts
- name: "create cronjob for arp -s (needed for wakeonlan)"
ansible.builtin.cron:
name: "setup crontab for arp for wakeonlan"
minute: "*"
hour: "*"
job: "/home/darkiop/bin/arp.sh >/dev/null 2>&1"
tags: crontab, crontab-arp
### rsync named backups to odin
- name: "copy backup_bind.sh"
become: true
become_user: "{{ user_username }}"
copy:
src: files/hosts/loki/backup_bind.sh
dest: ~/bin/
mode: 0755
tags: bind-backup, copy-scripts
- name: "create cronjob for backup_bind.sh"
ansible.builtin.cron:
name: "setup crontab for backup_bind.sh"
minute: "00"
hour: "12"
job: "/home/darkiop/bin/backup_bind.sh >/dev/null 2>&1"
tags: crontab, crontab-bind-backup, bind-backup