-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopi-playbook.yml
480 lines (427 loc) · 10.9 KB
/
opi-playbook.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
# vim: set ft=ansible
- hosts: oranges
remote_user: root
vars:
max_cpu_freq: 1000000
max_ram_freq: 600mhz
max_cpu_cores: 4
root_password: "$6$2Ze2W4nQf1IBxA/$mR/zNWA/KJJWe9vn6Irl8dx..Ntp2NOzTNulqgR3aAJJxgh0Vhj6dve7D6Q8IEiYg9/MgyctxwyOd2zgW7QPA/"
root_keys:
- "ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBAOeBfS1BakTxbEsu03pBkx+V2exaF9wvsmYA2X1/X4BBpoG1eOz7Tg3kapzXeCVDX+xWnGIkeJ3pzsHd8p4p6Qs7U3zsr9QPJugw5dHqbASkSfnnUAmZI/TMGVtkaVL0w== jan@JuiceSSH"
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEHuaqkHW/BGaz0th7nU8+fCngLzXZwhWOdTCyVLCDga jan@brettchen"
wifi_passwd: tent_controller_wifi
network: "10.33.33.1/24"
controller_ip: "{{ network|ipaddr(1) }}"
microcontrollers:
led:
ip: "{{ network|ipaddr(10) }}"
devices:
- "5c:cf:7f:f8:48:65"
data_port: 7000
control_port: 7001
gyro:
ip: "{{ network|ipaddr(20) }}"
devices:
- "5c:cf:7f:f8:47:ae"
- "5c:cf:7f:ff:42:6a"
data_port: 7002
syslog_port: 6656
update_port: 6655
frames_per_second: 35
sw_user: tent
repos:
controller: "https://github.com/Retardigrades/tent-update-controller.git"
visuals: "https://github.com/Retardigrades/visuals.git"
ir_proc: tent-ir
ir_commands:
- name: beat-toggle
url: /music/beat/toggle
buttons:
- button: A_POWER
repeat: 2
- button: B_POWER
repeat: 2
- name: seek
url: /music/seek/forward
buttons:
- button: A_AV
repeat: 2
- button: B_AV
repeat: 2
- name: vol-down
url: /music/voldown
buttons:
- button: A_MINUS
repeat: 2
- button: B_MINUS
repeat: 2
- name: vol-up
url: /music/volup
buttons:
- button: A_PLUS
repeat: 2
- button: B_PLUS
repeat: 2
- name: next-song
url: /music/next
buttons:
- button: A_DOWN
- button: B_DOWN
- name: next-effect
url: /effect/next
buttons:
- button: A_UP
- button: B_UP
venv_home: "/home/{{ sw_user }}/venv"
visuals_dir: "/home/{{ sw_user }}/visuals"
controller_dir: "/home/{{ sw_user }}/controller"
firmware_dir: "/home/{{ sw_user }}/firmware"
firmware:
- name: led_fw
file: led/firmware.bin
- name: gyro_fw
file: gyro/firmware.bin
music:
mount: /dev/sda
mountpoint: /mnt/music
path: oggtent
initial_volume: 0.6
tasks:
- name: set hostname
hostname: name={{ inventory_hostname }}
tags:
- base
- name: set root password
user:
name: root
password: "{{ root_password }}"
- name: add root ssh keys
authorized_key:
user: root
key: "{{ item }}"
state: present
with_items: "{{ root_keys }}"
tags:
- base
- name: update system
apt:
update_cache: yes
upgrade: yes
tags:
- upgrade
- name: install packages
apt:
name: "{{ item }}"
state: latest
with_items:
- vim
- tmux
- bridge-utils
- hostapd
- dnsmasq
- firmware-atheros
- firmware-realtek
- cmake
- libvorbis-dev
- portaudio19-dev
- python3-virtualenv
- virtualenv
- libboost-program-options-dev
- libboost-filesystem-dev
- libboost-system-dev
- python3-dev
- liblircclient-dev
- lirc
tags:
- base
- name: turn gpu off
command: /usr/bin/h3consumption -g off
tags:
- base
- name: lower mem speed
command: /usr/bin/h3consumption -d {{ max_ram_freq }}
tags:
- base
- name: set max cpu cores
command: /usr/bin/h3consumption -c {{ max_cpu_cores }}
tags:
- base
- name: set max cpu speed
template:
src: etc/default/cpufrequtils
dest: /etc/default/cpufrequtils
tags:
- base
- name: set hostapd defaults
template:
src: etc/default/hostapd
dest: /etc/default/hostapd
tags:
- ap
- name: create directory for ansible custom facts
file: state=directory recurse=yes path=/etc/ansible/facts.d
tags:
- ap
- name: install wpa psk fact
template:
src: etc/ansible/facts.d/wpa_psk.fact
dest: /etc/ansible/facts.d/wpa_psk.fact
mode: 0755
register: _wpa_fact
tags:
- ap
- name: reread facts
setup: filter=ansible_local
when: _wpa_fact|changed
tags:
- ap
- name: set hostapd config
template:
src: etc/hostapd.conf
dest: /etc/hostapd.conf
tags:
- ap
- name: install interfaces
template:
src: etc/network/interfaces
dest: /etc/network/interfaces
register: _networking
tags:
- ap
- name: networking restart
service:
name: networking
state: restarted
tags:
- ap
when: _networking|changed
- name: restart hostapd
service:
name: hostapd.service
state: restarted
enabled: true
tags:
- ap
- name: generate hosts entries
lineinfile:
dest: /etc/hosts
regexp: "{{ item.name | replace('.', '\\.') }}"
line: "{{ item.ip | ipaddr('address') }} {{ item.name }}"
with_items:
- name: led
ip: "{{ microcontrollers.led.ip }}"
- name: gyro
ip: "{{ microcontrollers.gyro.ip }}"
- name: controller
ip: "{{ network | ipaddr('1') }}"
tags:
- ap
- name: install dnsmasq config
template:
src: etc/dnsmasq.conf
dest: /etc/dnsmasq.conf
backup: yes
register: _dnsmasq_config
tags:
- ap
- name: restart dnsmasq
service:
name: dnsmasq.service
state: restarted
enabled: true
when: _dnsmasq_config|changed
tags:
- ap
- name: make sure we do not override resolv.conf
ini_file:
path: /etc/NetworkManager/NetworkManager.conf
section: main
option: dns
value: "none"
backup: yes
register: _nm_config
tags:
- ap
- name: restart network manager
service:
name: NetworkManager.service
state: restarted
enabled: yes
when: _nm_config|changed
tags:
- ap
- name: remove Network Manager resolv.conf
file:
path: /etc/resolv.conf
state: absent
when: _nm_config|changed
tags:
- ap
- name: setup resolv.conf
template:
src: etc/resolv.conf
dest: /etc/resolv.conf
tags:
- ap
- name: setup resolv.conf.google
template:
src: etc/resolv.conf.google
dest: /etc/resolv.conf.google
tags:
- ap
- name: sync filesystem
command: /bin/sync
tags:
- base
- ap
- name: setup syslog for udp
template:
src: etc/rsyslog.d/udp.conf
dest: /etc/rsyslog.d/udp.conf
tags:
- software
- name: restart syslog
service:
name: rsyslog.service
state: restarted
enabled: true
tags:
- software
- name: add user for tent software
user:
name: "{{ sw_user }}"
groups: audio,dialout,plugdev
shell: /bin/bash
state: present
tags:
- software
- name: setup lirc
copy:
src: etc/lirc/lircd.conf
dest: /etc/lirc/lircd.conf
tags:
- software
- name: install user lirc config
template:
src: home/.lircrc
dest: "/home/{{ sw_user }}/.lircrc"
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: set up virtualenv
pip:
virtualenv: "{{ venv_home }}"
virtualenv_python: python3
name: "{{ item }}"
with_items:
- Flask
- python-lirc
- requests
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: Setup controller software repo
git:
repo: "{{ repos.controller }}"
dest: "{{ controller_dir }}"
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: Setup visuals software repo
git:
repo: "{{ repos.visuals }}"
dest: "{{ visuals_dir }}"
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: Create visuals build dir
file:
name: "{{ visuals_dir }}/build"
state: directory
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: Run Cmake
command: "cmake -D CMAKE_BUILD_TYPE=Release .."
args:
chdir: "{{ visuals_dir }}/build"
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: Run Make
command: "make -j3"
args:
chdir: "{{ visuals_dir }}/build"
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: Create music mountpoint
file:
name: "{{ music.mountpoint }}"
mode: 777
state: directory
ignore_errors: yes
tags:
- software
- name: Add music to fstab
mount:
src: "{{ music.mount }}"
path: "{{ music.mountpoint }}"
fstype: vfat
state: present
opts: ro
tags:
- software
- name: Create visuals systemd file
template:
src: etc/systemd/system/visuals.service
dest: /etc/systemd/system/visuals.service
tags:
- software
- name: Create remote systemd file
template:
src: etc/systemd/system/remote_control.service
dest: /etc/systemd/system/remote_control.service
tags:
- software
- name: make firmware dir
file:
name: "{{ firmware_dir }}"
state: directory
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: copy firmware files
copy:
src: firmware/
dest: "{{ firmware_dir}}"
become: true
become_user: "{{ sw_user }}"
tags:
- software
- name: Create updater systemd file
template:
src: etc/systemd/system/firmware_updater.service
dest: /etc/systemd/system/firmware_updater.service
tags:
- software
- name: Restart services
systemd:
name: "{{ item }}"
state: restarted
enabled: true
daemon_reload: yes
with_items:
- remote_control.service
- visuals.service
- firmware_updater.service
tags:
- software