Parcourir la source

add lights-web to iot role

Thomas Buck il y a 2 ans
Parent
révision
55c30b3899

+ 5
- 0
roles/iot/defaults/main.yml Voir le fichier

@@ -22,3 +22,8 @@ grafana_db_database: grafana
22 22
 # must match values in roles/common
23 23
 db_admin_username: 'postgres'
24 24
 db_admin_password: "{{ lookup('password', secret + '/' + 'db_admin_password length=32') }}"
25
+
26
+lights_web_release: "https://git.xythobuz.de/thomas/lights-web/archive/master.zip"
27
+
28
+lights_web_username: "{{ main_user_name }}"
29
+lights_web_password: "{{ lookup('password', secret + '/' + 'mosquitto_main_user_password length=20 chars=hexdigits') }}"

+ 28
- 0
roles/iot/tasks/lights.yml Voir le fichier

@@ -0,0 +1,28 @@
1
+- name: Create temporary lights-web directory
2
+  file: state=directory path=/root/lights-web
3
+
4
+- name: Download lights-web source
5
+  get_url:
6
+    url="{{ lights_web_release }}"
7
+    dest=/root/lights-web/lights-web.zip
8
+
9
+- name: Remove old lights-web decompressed source
10
+  shell: rm -rf /root/lights-web/lights-web
11
+
12
+- name: Decompress lights-web release
13
+  unarchive: src=/root/lights-web/lights-web.zip
14
+             dest=/root/lights-web/ copy=no
15
+             creates=/root/lights-web/lights-web
16
+
17
+- name: Create lights-web webserver directory
18
+  file: state=directory path=/var/www/lights-web
19
+
20
+- name: Copy lights-web to webserver directory
21
+  shell: cp -R /root/lights-web/lights-web/* /var/www/lights-web
22
+
23
+- name: Create config file with lights-web credentials
24
+  template:
25
+    src=var_www_lights_web_lights_credentials.j2
26
+    dest=/var/www/lights-web/lights/credentials.js
27
+    owner=root
28
+    group=root

+ 1
- 0
roles/iot/tasks/main.yml Voir le fichier

@@ -3,3 +3,4 @@
3 3
 - include: mosquitto.yml tags=iot
4 4
 - include: mqtt_admin.yml tags=iot
5 5
 - include: nodered.yml tags=iot
6
+- include: lights.yml tags=iot

+ 3
- 0
roles/iot/templates/etc_apache2_sites-available_grafana.j2 Voir le fichier

@@ -23,6 +23,9 @@
23 23
     Alias                   /mqtt /var/www/mqtt-admin
24 24
     ProxyPassMatch          ^/mqtt !
25 25
 
26
+    Alias                   /lights /var/www/lights-web/lights
27
+    ProxyPassMatch          ^/lights !
28
+
26 29
     ProxyRequests           Off
27 30
     ProxyPreserveHost       On
28 31
 

+ 3
- 0
roles/iot/templates/var_www_lights_web_lights_credentials.j2 Voir le fichier

@@ -0,0 +1,3 @@
1
+const mqttUsername = '{{ lights_web_username }}'
2
+const mqttPassword = '{{ lights_web_password }}'
3
+const mqttUrl = 'wss://{{ server_fqdn }}:8083'

Chargement…
Annuler
Enregistrer