summaryrefslogtreecommitdiff
path: root/notification
diff options
context:
space:
mode:
authorRené Moser <mail@renemoser.net>2016-09-26 13:48:30 +0200
committerGitHub <noreply@github.com>2016-09-26 13:48:30 +0200
commitcbdc798ad218e41dff22364da11c83d1e6d71f8f (patch)
tree907d4275fd56fbd223539a3d8ae310813c876fa5 /notification
parentc1adb215f045ebe1c951878e475223583afc22b9 (diff)
downloadansible-modules-extras-cbdc798ad218e41dff22364da11c83d1e6d71f8f.tar.gz
twilio: fix false negative failure - sms was sent successfully (#3033)
Diffstat (limited to 'notification')
-rw-r--r--notification/twilio.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/notification/twilio.py b/notification/twilio.py
index 21652062..2c7275a3 100644
--- a/notification/twilio.py
+++ b/notification/twilio.py
@@ -161,8 +161,12 @@ def main():
for number in to_number:
r, info = post_twilio_api(module, account_sid, auth_token, msg,
from_number, number, media_url)
- if info['status'] != 200:
- module.fail_json(msg="unable to send message to %s" % number)
+ if info['status'] not in [200, 201]:
+ body_message = "unknown error"
+ if 'body' in info:
+ body = json.loads(info['body'])
+ body_message = body['message']
+ module.fail_json(msg="unable to send message to %s: %s" % (number, body_message))
module.exit_json(msg=msg, changed=False)