Merge pull request #101 from tobz-nz/patch-1
Update the webhook url for slack
This commit is contained in:
commit
e34f62bb1f
1 changed files with 4 additions and 5 deletions
|
@ -105,8 +105,7 @@ EXAMPLES = """
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
SLACK_INCOMING_WEBHOOK = 'https://hooks.slack.com/services/%s'
|
||||||
SLACK_INCOMING_WEBHOOK = 'https://%s/services/hooks/incoming-webhook?token=%s'
|
|
||||||
|
|
||||||
def build_payload_for_slack(module, text, channel, username, icon_url, icon_emoji, link_names, parse):
|
def build_payload_for_slack(module, text, channel, username, icon_url, icon_emoji, link_names, parse):
|
||||||
payload = dict(text=text)
|
payload = dict(text=text)
|
||||||
|
@ -128,11 +127,11 @@ def build_payload_for_slack(module, text, channel, username, icon_url, icon_emoj
|
||||||
return payload
|
return payload
|
||||||
|
|
||||||
def do_notify_slack(module, domain, token, payload):
|
def do_notify_slack(module, domain, token, payload):
|
||||||
slack_incoming_webhook = SLACK_INCOMING_WEBHOOK % (domain, token)
|
slack_incoming_webhook = SLACK_INCOMING_WEBHOOK % (token)
|
||||||
|
|
||||||
response, info = fetch_url(module, slack_incoming_webhook, data=payload)
|
response, info = fetch_url(module, slack_incoming_webhook, data=payload)
|
||||||
if info['status'] != 200:
|
if info['status'] != 200:
|
||||||
obscured_incoming_webhook = SLACK_INCOMING_WEBHOOK % (domain, '[obscured]')
|
obscured_incoming_webhook = SLACK_INCOMING_WEBHOOK % ('[obscured]')
|
||||||
module.fail_json(msg=" failed to send %s to %s: %s" % (payload, obscured_incoming_webhook, info['msg']))
|
module.fail_json(msg=" failed to send %s to %s: %s" % (payload, obscured_incoming_webhook, info['msg']))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in a new issue