From 91277fc0c7e0b9f5ab617aa83880098900da101f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Mon, 26 Sep 2016 13:48:30 +0200 Subject: [PATCH] twilio: fix false negative failure - sms was sent successfully (#3033) --- lib/ansible/modules/extras/notification/twilio.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/notification/twilio.py b/lib/ansible/modules/extras/notification/twilio.py index 216520620f..2c7275a3e9 100644 --- a/lib/ansible/modules/extras/notification/twilio.py +++ b/lib/ansible/modules/extras/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)