aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-13 15:00:24 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-13 15:05:22 +0200
commit123ee097b8c8f69e8cade9f618585065d3fc7948 (patch)
tree469cce807b0cb53c88e0a5e3aae3bafad53644ff /modules
parent6b95d3bd38307c1bd320a16368d0a3753601730d (diff)
downloadPuppet-123ee097b8c8f69e8cade9f618585065d3fc7948.tar.gz
Puppet-123ee097b8c8f69e8cade9f618585065d3fc7948.tar.zst
Puppet-123ee097b8c8f69e8cade9f618585065d3fc7948.zip
Add logger username
Diffstat (limited to 'modules')
-rw-r--r--modules/role/manifests/cryptoportfolio/front.pp2
-rw-r--r--modules/role/templates/cryptoportfolio/api_logger.py.erb3
2 files changed, 4 insertions, 1 deletions
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 {
145 145
146 # Slack logger 146 # Slack logger
147 $slack_logger = lookup("role::cryptoportfolio::front::slack_logger") 147 $slack_logger = lookup("role::cryptoportfolio::front::slack_logger")
148 $slack_logger_username = lookup("role::cryptoportfolio::front::slack_logger_username", { "default_value" => "Logger" })
149
148 unless empty($slack_logger) { 150 unless empty($slack_logger) {
149 file { "/usr/local/bin/api_logger": 151 file { "/usr/local/bin/api_logger":
150 mode => "0755", 152 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()
9http = urllib3.PoolManager() 9http = urllib3.PoolManager()
10 10
11webhook_url = "<%= @slack_logger %>" 11webhook_url = "<%= @slack_logger %>"
12webhook_username = "<%= @slack_logger_username %>"
12webhook_icon = "https://git.immae.eu/releases/logger.png" 13webhook_icon = "https://git.immae.eu/releases/logger.png"
13 14
14def send_to_discord(message): 15def send_to_discord(message):
15 def send_chunk(chunk): 16 def send_chunk(chunk):
16 data = { 17 data = {
17 "avatar_url": webhook_icon, 18 "avatar_url": webhook_icon,
18 "username": "Logger", 19 "username": webhook_username,
19 "content": "```\n{}\n```".format(chunk), 20 "content": "```\n{}\n```".format(chunk),
20 } 21 }
21 encoded = json.dumps(data).encode('utf-8') 22 encoded = json.dumps(data).encode('utf-8')