From 123ee097b8c8f69e8cade9f618585065d3fc7948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 13 May 2018 15:00:24 +0200 Subject: Add logger username --- modules/role/manifests/cryptoportfolio/front.pp | 2 ++ modules/role/templates/cryptoportfolio/api_logger.py.erb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/role/manifests/cryptoportfolio/front.pp b/modules/role/manifests/cryptoportfolio/front.pp index a6b25c4..3612fd5 100644 --- a/modules/role/manifests/cryptoportfolio/front.pp +++ b/modules/role/manifests/cryptoportfolio/front.pp @@ -145,6 +145,8 @@ class role::cryptoportfolio::front inherits role::cryptoportfolio { # Slack logger $slack_logger = lookup("role::cryptoportfolio::front::slack_logger") + $slack_logger_username = lookup("role::cryptoportfolio::front::slack_logger_username", { "default_value" => "Logger" }) + unless empty($slack_logger) { file { "/usr/local/bin/api_logger": mode => "0755", diff --git a/modules/role/templates/cryptoportfolio/api_logger.py.erb b/modules/role/templates/cryptoportfolio/api_logger.py.erb index e5f0b30..3fb14a0 100644 --- a/modules/role/templates/cryptoportfolio/api_logger.py.erb +++ b/modules/role/templates/cryptoportfolio/api_logger.py.erb @@ -9,13 +9,14 @@ urllib3.disable_warnings() http = urllib3.PoolManager() webhook_url = "<%= @slack_logger %>" +webhook_username = "<%= @slack_logger_username %>" webhook_icon = "https://git.immae.eu/releases/logger.png" def send_to_discord(message): def send_chunk(chunk): data = { "avatar_url": webhook_icon, - "username": "Logger", + "username": webhook_username, "content": "```\n{}\n```".format(chunk), } encoded = json.dumps(data).encode('utf-8') -- cgit v1.2.3