diff options
Diffstat (limited to 'modules/role/files')
-rw-r--r-- | modules/role/files/cryptoportfolio/slack-notify.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/role/files/cryptoportfolio/slack-notify.py b/modules/role/files/cryptoportfolio/slack-notify.py new file mode 100644 index 0000000..fe64fb6 --- /dev/null +++ b/modules/role/files/cryptoportfolio/slack-notify.py | |||
@@ -0,0 +1,27 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | |||
3 | import sys | ||
4 | import json | ||
5 | import urllib3 | ||
6 | |||
7 | project = sys.argv[1] | ||
8 | url = sys.argv[2] | ||
9 | version = sys.argv[3] | ||
10 | |||
11 | def post(url, data): | ||
12 | urllib3.disable_warnings() | ||
13 | http = urllib3.PoolManager() | ||
14 | |||
15 | encoded = data.encode('utf-8') | ||
16 | |||
17 | r = http.request("POST", url, | ||
18 | headers={'Content-Type': 'application/json'}, | ||
19 | body=encoded) | ||
20 | |||
21 | data = { | ||
22 | "icon_url": "https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png", | ||
23 | "text": "Deployed {} on {}".format(version, project), | ||
24 | } | ||
25 | |||
26 | json_data = json.dumps(data) | ||
27 | post(url, json_data) | ||