2 Commits

Author SHA1 Message Date
  Thomas Buck 55c30b3899 add lights-web to iot role 1 year ago
  Thomas Buck 9163ee8ecb fix for missing python3-psycopg2 on debian 10 1 year ago

+ 1
- 0
roles/common/tasks/postgres.yml View File

@@ -21,6 +21,7 @@
21 21
     packages:
22 22
     - postgresql
23 23
     - python-psycopg2
24
+    - python3-psycopg2
24 25
   tags:
25 26
     - dependencies
26 27
   when: ansible_distribution_version == '10'

+ 5
- 0
roles/iot/defaults/main.yml View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

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

Loading…
Cancel
Save