diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-05 17:29:29 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-05 17:36:54 +0100 |
commit | a4c92ff7477d09b480cab028411bc7c6b250604e (patch) | |
tree | 5a8394a64cf4a1d3fb9ffcdb3c8ed3328b94fb79 /modules/role/files | |
parent | d765eedf28199f6723dee5dab7c81a357be86f72 (diff) | |
download | Puppet-a4c92ff7477d09b480cab028411bc7c6b250604e.tar.gz Puppet-a4c92ff7477d09b480cab028411bc7c6b250604e.tar.zst Puppet-a4c92ff7477d09b480cab028411bc7c6b250604e.zip |
Add notification for app deployment
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) | ||