aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/role/files/cryptoportfolio/slack-notify.py19
-rw-r--r--modules/role/manifests/cryptoportfolio.pp18
2 files changed, 31 insertions, 6 deletions
diff --git a/modules/role/files/cryptoportfolio/slack-notify.py b/modules/role/files/cryptoportfolio/slack-notify.py
index fe64fb6..dfced46 100644
--- a/modules/role/files/cryptoportfolio/slack-notify.py
+++ b/modules/role/files/cryptoportfolio/slack-notify.py
@@ -1,12 +1,18 @@
1#!/usr/bin/env python3 1#!/usr/bin/env python3
2 2
3import os
3import sys 4import sys
4import json 5import json
5import urllib3 6import urllib3
6 7
7project = sys.argv[1] 8project = os.environ["P_PROJECT"]
8url = sys.argv[2] 9url = os.environ["P_WEBHOOK"]
9version = sys.argv[3] 10version = os.environ["P_VERSION"]
11host = os.environ["P_HOST"]
12if os.environ["P_HTTPS"] == "true":
13 scheme = "https://"
14else:
15 scheme = "http://"
10 16
11def post(url, data): 17def post(url, data):
12 urllib3.disable_warnings() 18 urllib3.disable_warnings()
@@ -20,7 +26,12 @@ def post(url, data):
20 26
21data = { 27data = {
22 "icon_url": "https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png", 28 "icon_url": "https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png",
23 "text": "Deployed {} on {}".format(version, project), 29 "text": "Deployed {} of {} on {}{}".format(
30 version,
31 project,
32 scheme,
33 host,
34 ),
24 } 35 }
25 36
26json_data = json.dumps(data) 37json_data = json.dumps(data)
diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp
index 67d88fb..bec247e 100644
--- a/modules/role/manifests/cryptoportfolio.pp
+++ b/modules/role/manifests/cryptoportfolio.pp
@@ -272,7 +272,14 @@ class role::cryptoportfolio {
272 unless empty($cf_webhook_url) { 272 unless empty($cf_webhook_url) {
273 exec { "bot-slack-notify": 273 exec { "bot-slack-notify":
274 refreshonly => true, 274 refreshonly => true,
275 command => "/usr/local/bin/slack-notify Trader '${cf_webhook_url}' '${bot_version}'", 275 environment => [
276 "P_PROJECT=Trader",
277 "P_WEBHOOK=${cf_webhook_url}",
278 "P_VERSION=${bot_version}",
279 "P_HOST=${cf_front_app_host}",
280 "P_HTTPS=${cf_front_app_ssl}",
281 ],
282 command => "/usr/local/bin/slack-notify",
276 require => File["/usr/local/bin/slack-notify"], 283 require => File["/usr/local/bin/slack-notify"],
277 subscribe => Exec["py-cryptoportfolio-dependencies"], 284 subscribe => Exec["py-cryptoportfolio-dependencies"],
278 } 285 }
@@ -407,7 +414,14 @@ class role::cryptoportfolio {
407 unless empty($cf_webhook_url) { 414 unless empty($cf_webhook_url) {
408 exec { "front-slack-notify": 415 exec { "front-slack-notify":
409 refreshonly => true, 416 refreshonly => true,
410 command => "/usr/local/bin/slack-notify Front '${cf_webhook_url}' '${front_version}'", 417 environment => [
418 "P_PROJECT=Front",
419 "P_WEBHOOK=${cf_webhook_url}",
420 "P_VERSION=${front_version}",
421 "P_HOST=${cf_front_app_host}",
422 "P_HTTPS=${cf_front_app_ssl}",
423 ],
424 command => "/usr/local/bin/slack-notify",
411 require => File["/usr/local/bin/slack-notify"], 425 require => File["/usr/local/bin/slack-notify"],
412 subscribe => [Exec["go-cryptoportfolio-app"], Exec["web-cryptoportfolio-build"]], 426 subscribe => [Exec["go-cryptoportfolio-app"], Exec["web-cryptoportfolio-build"]],
413 } 427 }