Ver código fonte

Ansible adaptions

master
Dirk Alders 9 meses atrás
pai
commit
51c0b9eaa9
3 arquivos alterados com 25 adições e 9 exclusões
  1. 3
    3
      z_server/config_example/config.j2
  2. 21
    5
      z_server/init_venv
  3. 1
    1
      z_server/mqtt

z_server/config_example/config.py → z_server/config_example/config.j2 Ver arquivo

@@ -5,9 +5,9 @@ LOGLEVEL = logging.INFO
5 5
 
6 6
 APP_NAME = "z_monitor"
7 7
 
8
-MQTT_SERVER = "<hostname>"
8
+MQTT_SERVER = "{{ server_nagios_hostname }}"
9 9
 MQTT_PORT = 1883
10
-MQTT_USER = "<username>"
11
-MQTT_PASSWORD = "<password>"
10
+MQTT_USER = "{{ server_nagios_username }}"
11
+MQTT_PASSWORD = "{{ server_nagios_password }}"
12 12
 
13 13
 SOCK_PROT_PORT = 8380

+ 21
- 5
z_server/init_venv Ver arquivo

@@ -1,8 +1,24 @@
1
-#!/bin/sh
1
+#!/bin/bash
2 2
 #
3 3
 BASEPATH=`realpath $(dirname $0)`
4 4
 
5
-python3 -m venv $BASEPATH/venv
6
-$BASEPATH/venv/bin/pip install --upgrade pip
7
-find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r
8
-$BASEPATH/venv/bin/pip list --outdated --format=json | jq -r '.[] | .name'|xargs -n1 $BASEPATH/venv/bin/pip install -U
5
+#
6
+# Create venv
7
+#
8
+if [[ ! -e $BASEPATH/venv ]]; then
9
+    python3 -m venv $BASEPATH/venv > /dev/null 2>&1
10
+    # $BASEPATH/venv/bin/pip install --upgrade pip
11
+    find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r > /dev/null 2>&1
12
+    echo "venv changed"
13
+fi
14
+#
15
+# Update venv modules
16
+#
17
+for req_mod in $($BASEPATH/venv/bin/pip list --format=json | jq -r '.[] | .name'); do
18
+     $BASEPATH/venv/bin/pip install -U $req_mod | grep install > /dev/null 2>&1
19
+     if [[ "$?" -eq "0" ]]; then
20
+         echo $req_mod changed
21
+     fi
22
+
23
+done
24
+#|xargs -n1 $BASEPATH/venv/bin/pip install -U

+ 1
- 1
z_server/mqtt

@@ -1 +1 @@
1
-Subproject commit 1adfb0626e7777c6d29be65d4ad4ce2d57541301
1
+Subproject commit 328d3471a748472695a61193becdda76c7eefe69

Carregando…
Cancelar
Salvar