From 51c0b9eaa98190969913d0731814e07817a9da5b Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 24 Mar 2024 13:19:07 +0100 Subject: [PATCH] Ansible adaptions --- .../config_example/{config.py => config.j2} | 6 ++--- z_server/init_venv | 26 +++++++++++++++---- z_server/mqtt | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) rename z_server/config_example/{config.py => config.j2} (64%) diff --git a/z_server/config_example/config.py b/z_server/config_example/config.j2 similarity index 64% rename from z_server/config_example/config.py rename to z_server/config_example/config.j2 index 2a9b2ba..5a8ccf4 100644 --- a/z_server/config_example/config.py +++ b/z_server/config_example/config.j2 @@ -5,9 +5,9 @@ LOGLEVEL = logging.INFO APP_NAME = "z_monitor" -MQTT_SERVER = "" +MQTT_SERVER = "{{ server_nagios_hostname }}" MQTT_PORT = 1883 -MQTT_USER = "" -MQTT_PASSWORD = "" +MQTT_USER = "{{ server_nagios_username }}" +MQTT_PASSWORD = "{{ server_nagios_password }}" SOCK_PROT_PORT = 8380 diff --git a/z_server/init_venv b/z_server/init_venv index 428ff04..9f00515 100755 --- a/z_server/init_venv +++ b/z_server/init_venv @@ -1,8 +1,24 @@ -#!/bin/sh +#!/bin/bash # BASEPATH=`realpath $(dirname $0)` -python3 -m venv $BASEPATH/venv -$BASEPATH/venv/bin/pip install --upgrade pip -find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r -$BASEPATH/venv/bin/pip list --outdated --format=json | jq -r '.[] | .name'|xargs -n1 $BASEPATH/venv/bin/pip install -U +# +# Create venv +# +if [[ ! -e $BASEPATH/venv ]]; then + python3 -m venv $BASEPATH/venv > /dev/null 2>&1 + # $BASEPATH/venv/bin/pip install --upgrade pip + find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r > /dev/null 2>&1 + echo "venv changed" +fi +# +# Update venv modules +# +for req_mod in $($BASEPATH/venv/bin/pip list --format=json | jq -r '.[] | .name'); do + $BASEPATH/venv/bin/pip install -U $req_mod | grep install > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + echo $req_mod changed + fi + +done +#|xargs -n1 $BASEPATH/venv/bin/pip install -U diff --git a/z_server/mqtt b/z_server/mqtt index 1adfb06..328d347 160000 --- a/z_server/mqtt +++ b/z_server/mqtt @@ -1 +1 @@ -Subproject commit 1adfb0626e7777c6d29be65d4ad4ce2d57541301 +Subproject commit 328d3471a748472695a61193becdda76c7eefe69