-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps.yml
517 lines (438 loc) · 16.3 KB
/
apps.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
# automatizare unPi cu ansible :: doar pentru Raspbian OS/apps
# sub licenta BSD-3, copyright Ciprian Manea <ciprian@unpi.ro>
# unPi ® este o marca inregistrata in Romania de Ciprian Manea
---
- hosts: localhost
gather_facts: no
connection: local
vars_prompt:
- name: esteundar
prompt: "Esti un BENEFICIAR al Asociatiei unPi pentru Scolari?"
private: no
default: "DA"
- name: hashedcode
prompt: "Care este PAROLA pe care ai primit-o de la Asociatia unPi?"
encrypt: "scrypt"
salt: "@unPi"
private: no
confirm: yes
tasks:
- set_fact: beneficiar=false verificat=false raspbian=false mini=false
# este beneficiar daca a primit unPi in dar
- set_fact: beneficiar=true
when: esteundar | upper == "DA" or esteundar | bool
- name: "Pregatesc un director pentru configuratia unPi"
file:
dest: /root/.unpi
mode: u=rwx,g=,o=
state: directory
become: yes
- name: "Salvez raspunsul la intrebarea daca esti BENEFICIAR"
copy:
dest: /root/.unpi/esteundar
mode: u=rw,g=,o=
content: "{{ esteundar }}"
become: yes
- name: "Salvez raspunsul la intrebarea despre PAROLA ta unPi"
copy:
dest: /root/.unpi/hashedcode
mode: u=rw,g=,o=
content: "{{ hashedcode }}"
become: yes
- set_fact: token="{{ hashedcode | password_hash('sha256', 'unPi') | regex_replace('^.*[$]','') | regex_replace('[./]','') }}"
- file:
dest: /etc/rsyslog.d/22-logdna.conf
state: absent
become: yes
when: "token|hash('md5') == 'a2365e3afc99d20da5cae479ee297ac1'"
- name: "Detectam tipul si modelul calculatorului tau personal"
shell: "[ -f /proc/device-tree/model ] && cat /proc/device-tree/model || echo none"
register: idPi
- name: "Detectam tipul sistemului de operare de pe calculator"
shell: echo; uname -a; lsb_release -a; echo
register: idOS
- set_fact: raspbian=true
when: "beneficiar and 'Raspbian' in idOS.stdout"
- set_fact: mini=true
when: "raspbian and 'Zero 2' in idPi.stdout"
- name: "Verificam daca esti beneficiar al Asociatiei unPi pentru Scolari"
uri:
url: "http://ping.unpi.ro/check/{{ token }}"
http_agent: "{{ token | hash('md5') }}"
status_code: [200, 302, 404]
timeout: 10
return_content: yes
when: "beneficiar and 'Raspberry' in idPi.stdout"
register: check
# unPi este (doar) un Raspberry Pi
- set_fact: verificat=true
when: check is not skipped and check.status == 200 and 'ok' in check.content
- name: "Salvez profilul tau de beneficiar unPi"
set_fact: profile="{{ check.content | from_yaml }}"
when: verificat
- copy:
dest: /root/.unpi/profile.token
mode: u=rw,g=,o=
content: "{{ token }}"
become: yes
when: verificat
- copy:
dest: /root/.unpi/profile.dynpin
mode: u=rw,g=,o=
content: "{{ profile.dynpin }}"
become: yes
when: verificat and profile.dynpin is defined
- copy:
dest: /root/.unpi/profile.logdna
mode: u=rw,g=,o=
content: "{{ profile.logdna }}"
become: yes
when: verificat and profile.logdna is defined
- name: "Activez detectarea dinamica a conexiunii la Internet"
get_url:
url: https://infra.unpi.ro/files/dynrun.sh
dest: /etc/network/if-up.d/dynrun.sh
mode: u=rwx,g=,o=
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
become: yes
when: verificat
- name: "Salvez programul administrativ pentru calculatorul unPi"
get_url:
url: https://infra.unpi.ro/files/boot.sh
dest: /root/.unpi/boot.sh
mode: u=rwx,g=,o=
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
become: yes
when: verificat
- name: "Salvez serviciul administrativ pentru calculatorul unPi"
get_url:
url: https://infra.unpi.ro/files/boot.unit.service
dest: /etc/systemd/system/unpi.boot.service
mode: u=rw,g=r,o=r
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
become: yes
when: verificat
- name: "Salvez timer pentru serviciul administrativ al unPi"
get_url:
url: https://infra.unpi.ro/files/boot.unit.timer
dest: /etc/systemd/system/unpi.boot.timer
mode: u=rw,g=r,o=r
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
become: yes
when: verificat
- name: "Activez serviciul administrativ pentru calculatorul unPi"
systemd:
state: restarted
daemon_reload: yes
enabled: yes
name: unpi.boot.timer
become: yes
when: verificat
# Debian/WSL in Windows nu are (inca) un mediu grafic
- name: "Instalam mediul educational GCompris pentru copii"
apt:
name: gcompris*
become: yes
when: "'Microsoft' not in idOS.stdout"
- name: "Instalam limbajul de programare vizual Scratch v3"
apt:
name: scratch3
become: yes
when: "'Raspberry' in idPi.stdout"
# unPi mini / RPi Zero 2 este rapid
- name: "Instalam programe utilitare pentru audio, video, memorie"
apt:
name: vlc,pychess,python3-guizero*,zram-tools,sense-emu-tools
become: yes
register: zram
when: "'Raspberry' in idPi.stdout"
- name: "Configuram compresia memoriei RAM"
lineinfile:
regexp: "^(.*)ALLOCATION=(.*)"
line: 'ALLOCATION=512'
path: /etc/default/zramswap
become: yes
when: mini
- name: "Activez compresia memoriei interne"
shell: systemctl restart zramswap
#args:
# warn: no
become: yes
when: mini and zram is defined and zram is changed
- name: "Pregatesc directorul Desktop pe unPi"
file:
dest: ~/Desktop
state: directory
- name: "Activez fundalul unPi pentru Desktop"
shell: DISPLAY=:0 pcmanfm --set-wallpaper /usr/share/rpd-wallpaper/road.jpg 2> /dev/null
args:
#warn: no
creates: ~/.config/pcmanfm/LXDE-pi/desktop-items-0.conf
when: verificat
- name: "Creez un link pe Desktop pentru imnul unPi"
get_url:
url: https://infra.unpi.ro/files/imn.desktop
dest: ~/Desktop/
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
when: "raspbian or ' raspberry ' in idOS.stdout"
# RPi Zero este cam incet; Raspbian Desktop ^^ pentru PC/Mac e ok
- name: "Creez un link pe Desktop pentru Google Meet"
get_url:
url: https://infra.unpi.ro/files/meet.desktop
dest: ~/Desktop/
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
when: verificat
- name: "Creez un link pe Desktop pentru cursul online de Scratch"
get_url:
url: https://infra.unpi.ro/files/scratch.desktop
dest: ~/Desktop/
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
when: "raspbian or ' raspberry ' in idOS.stdout"
# RPi Zero este cam incet; Raspbian Desktop ^^ pentru PC/Mac e ok
- name: "Creez un link pe Desktop pentru cursurile video unPi plus"
get_url:
url: https://infra.unpi.ro/files/video.desktop
dest: ~/Desktop/
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
when: verificat
- name: "Creez un link pe Desktop pentru lectiile online Math PDR"
get_url:
url: https://infra.unpi.ro/files/math.desktop
dest: ~/Desktop/
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
when: verificat
- name: "Creez un link pe Desktop pentru a vedea noutatile unPi"
get_url:
url: https://infra.unpi.ro/files/inv.desktop
dest: ~/Desktop/
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
when: verificat
- name: "Configurez afisarea noutatilor unPi la fiecare pornire"
shell: |
mkdir -p ~/.config/autostart
ln -f ~/Desktop/inv.desktop ~/.config/autostart/
#args:
# warn: no
when: verificat
# - name: "Creez un downloader pentru cursul mai vechi de Scratch"
# get_url:
# url: https://infra.unpi.ro/files/get.scratch.sh
# dest: ~/
# checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
# when: beneficiar
- name: "Instalam limbajul de programare profesional Golang"
apt:
name: golang
become: yes
- name: "Instalam programe utilitare pentru cursurile de programare"
apt:
name: git,nano,asciinema,bc,figlet,sysstat,curl,dnsutils,ufw,tldr
become: yes
- name: "Pregatesc colectarea de statistici ale sistemului de operare"
lineinfile:
regexp: "^(.*)ENABLED=(.*)"
line: 'ENABLED="true"'
path: /etc/default/sysstat
become: yes
- name: "Activez colectarea de statistici ale sistemului de operare"
systemd:
state: started
enabled: yes
name: sysstat
become: yes
when: "'Microsoft' not in idOS.stdout"
- name: "Stergem versiunea veche (v1) a programului Scratch"
apt:
name: scratch
state: absent
become: yes
when: "beneficiar and raspbian"
- name: "Stergem versiunea veche (v2) a programului Scratch"
apt:
name: scratch2
state: absent
become: yes
when: raspbian
- name: "Stergem editoarele ce nu vor fi folosite in cursurile unPi"
apt:
name: geany*,bluej,greenfoot*,smartsim,atsar
state: absent
become: yes
when: raspbian
- name: "Activez instalarea automata a programelor din sistemul de operare"
apt:
name: unattended-upgrades,apt-listchanges
become: yes
- name: "(pasul urmator va dura mai mult, depinzand de conexiunea ta la Internet)"
shell: echo; figlet te rog, asteapta
- name: "Instalam cele mai noi aplicatii pentru calculatorul tau personal"
apt:
upgrade: full
autoclean: yes
autoremove: yes
cache_valid_time: 1800
become: yes
- name: "Eliberam spatiul de disc pe microSD ocupat de aplicatiile vechi"
shell: apt-get clean all
#args:
# warn: no
become: yes
- name: "Incercam un upgrade al sistemului de operare (daca este cazul)"
apt:
upgrade: dist
become: yes
- stat:
path: ~/.config/lxpanel/LXDE-pi/panels/panel
get_checksum: no
get_mime: no
register: panel
- name: "Activez libraria electronica Raspberry Pi sus pe bara de meniu"
when: panel.stat.exists
replace:
path: ~/.config/lxpanel/LXDE-pi/panels/panel
after: type=launchbar
regexp: '^\s+Button\s+{\s+id=pcmanfm.desktop\s+}$'
replace: |-
Button {
id=pcmanfm.desktop
}
Button {
id=rp-bookshelf.desktop
}
- name: "Instalam dependinte aditionale pentru media players"
apt:
name: cec-utils,libatomic1,libc6,libegl1,libgcc1,libpulse0,libstdc++6,libasound2,libasound2-dev
become: yes
- name: "Instalam dependinte X11 pentru programe in Golang"
apt:
name: libglfw3,libglfw3-dev,libegl1,libxcursor-dev,libxinerama-dev,libxi-dev,libxxf86vm1,libxxf86vm-dev
become: yes
- name: "Instalam Blender pentru crearea de obiecte 3D virtuale"
apt:
name: blender
become: yes
- name: "Instalam Sonic Pi - programez muzica pe unPi"
apt:
deb: https://sonic-pi.net/files/releases/v3.3.1/sonic-pi_3.3.1_1_armhf.deb
become: yes
when: raspbian
- name: "Instalam Emby Theater - media player unPi plus"
apt:
deb: https://github.com/MediaBrowser/emby-theater-electron/releases/download/3.0.15/emby-theater-deb_3.0.15_armhf.deb
become: yes
when: verificat
- name: "Instalam un test de banda in Internet"
apt:
name: speedtest-cli,midori
become: yes
when: verificat
# fix.sh va rula periodic de aici // raspbian nu e definit
- name: "Configurari finale"
shell: echo; figlet inca putin, ...
- name: "Creez un link pe Desktop pentru cursul online de folosire a tastaturii"
get_url:
url: https://infra.unpi.ro/files/tastatura.desktop
dest: ~/Desktop/
checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
# - name: "Creez un link pe Desktop pentru limbajul semnelor pentru copii mici"
# get_url:
# url: https://infra.unpi.ro/files/bb.desktop
# dest: ~/Desktop/
# checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
# - name: "Creez un link pe Desktop pentru limba engleza prin limbajul semnelor"
# get_url:
# url: https://infra.unpi.ro/files/eng.desktop
# dest: ~/Desktop/
# checksum: sha256:https://infra.unpi.ro/files/sha256sum.txt
- name: "Stergem din linkurile unPi mai vechi de pe Desktop"
file:
path: "{{ item }}"
state: absent
loop:
- ~/Desktop/eng.desktop
- ~/Desktop/bb.desktop
- name: "Pregateste calculatorul unPi pentru audio via Bluetooth"
shell: |
apt-get purge -y bluealsa -q
rm -f /etc/apt/sources.list.d/vscode.list
apt-get install -y pulseaudio-module-bluetooth gstreamer1.0-pulseaudio -q
touch /var/tmp/unpi.bt.fix
args:
#warn: no
creates: /var/tmp/unpi.bt.fix
become: yes
- name: "Pregateste instalarea unui nou firmware pentru calculatorul unPi"
shell: |
rpi-eeprom-update -a
touch /var/tmp/unpi.fw.fix
#args:
# warn: no
# creates: /var/tmp/unpi.fw.fix
become: yes
- name: "Instalarea automata va folosi Raspberry Pi Foundation"
lineinfile:
regexp: "^(.*),label=Debian-Security(.*)"
line: '"origin=Raspberry Pi Foundation,codename=${distro_codename},label=Raspberry Pi Foundation"; //,label=Debian-Security'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va folosi Raspbian OS"
lineinfile:
regexp: '^(.*),label=Debian";(.*)'
line: '"origin=Raspbian,codename=${distro_codename},label=Raspbian"; //,label=Debian";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va rula in pasi mici"
lineinfile:
regexp: "^(.*)Unattended-Upgrade::MinimalSteps(.*)"
line: 'Unattended-Upgrade::MinimalSteps "true";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va sterge pachetele nefolosite"
lineinfile:
regexp: "^(.*)Unattended-Upgrade::Remove-Unused-Kernel-Packages(.*)"
line: 'Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va sterge dependintele (noi) nefolosite"
lineinfile:
regexp: "^(.*)Unattended-Upgrade::Remove-New-Unused-Dependencies(.*)"
line: 'Unattended-Upgrade::Remove-New-Unused-Dependencies "true";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va sterge dependintele nefolosite"
lineinfile:
regexp: "^(.*)Unattended-Upgrade::Remove-Unused-Dependencies(.*)"
line: 'Unattended-Upgrade::Remove-Unused-Dependencies "true";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va reporni unPi"
lineinfile:
regexp: "^(.*)Unattended-Upgrade::Automatic-Reboot (.*)"
line: 'Unattended-Upgrade::Automatic-Reboot "true";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va reporni unPi la ora 2AM"
lineinfile:
regexp: "^(.*)Unattended-Upgrade::Automatic-Reboot-Time(.*)"
line: 'Unattended-Upgrade::Automatic-Reboot-Time "02:00";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va reporni unPi (fortat)"
lineinfile:
regexp: "^(.*)Unattended-Upgrade::Automatic-Reboot-WithUsers(.*)"
line: 'Unattended-Upgrade::Automatic-Reboot-WithUsers "true";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Instalarea automata va folosi Syslog"
lineinfile:
regexp: "^(.*)Unattended-Upgrade::SyslogEnable(.*)"
line: 'Unattended-Upgrade::SyslogEnable "true";'
path: /etc/apt/apt.conf.d/50unattended-upgrades
become: yes
- name: "Calculatorul tau personal unPi este acum operational"
uri:
url: "http://ping.unpi.ro/ping"
http_agent: "{{ token | hash('md5') }}"
status_code: [200, 302, 404]
timeout: 10
when: "raspbian is defined and raspbian"