From 24af872e85ae6a7317a4b83f6518eb70ac6e1088 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 3 Sep 2023 14:25:01 +0200 Subject: [PATCH] telegraf/hamstats: template mqtt user and password via env files --- 2configs/stats/telegraf/hamstats.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/2configs/stats/telegraf/hamstats.nix b/2configs/stats/telegraf/hamstats.nix index a0ea66a..887ffe7 100644 --- a/2configs/stats/telegraf/hamstats.nix +++ b/2configs/stats/telegraf/hamstats.nix @@ -3,8 +3,8 @@ let genTopic_zigbee = name: tags: { servers = [ "tcp://localhost:1883" ]; - username = "stats"; - passwordFile = config.sops.secrets."mqtt/stats".path; + username = "$HOME_MQTT_USER"; + password = "$HOME_MQTT_PASSWORD"; qos = 0; connection_timeout = "30s"; topics = [ "/ham/zigbee/${name}" ]; @@ -18,8 +18,8 @@ let }; genTopic_plain = name: topic: tags: { servers = [ "tcp://localhost:1883" ]; - username = "stats"; - passwordFile = config.sops.secrets."mqtt/stats".path; + username = "$HOME_MQTT_USER"; + password = "$HOME_MQTT_PASSWORD"; qos = 0; connection_timeout = "30s"; topics = [ topic ]; @@ -56,7 +56,10 @@ let (esensor room name ''${room}_${name}_pressure'') ]; in { - sops.secrets."mqtt/stats" = {}; + sops.secrets."mqtt/stats.env" = {}; + services.telegraf.environmentFiles = [ + config.sops.secrets."mqtt/stats.env".path + ]; services.telegraf.extraConfig.inputs.mqtt_consumer = (zigbee_temphum "Wohnzimmer" "temp1") ++ (zigbee_temphum "Badezimmer" "temp2")