From f0508fa30ea6d98431dc2600792e333b86c67cd8 Mon Sep 17 00:00:00 2001 From: Jean-Fred Berthelot Date: Sat, 25 Apr 2015 12:56:35 +0100 Subject: [PATCH] Add check_mode support to HipChat module The HipChat module declares to support check_mode, but the message is sent in any case. With this, if executed in check mode, the module will exit before actually sending the message to HipChat. It will return changed=False, as per the convention for notifications modules. --- notification/hipchat.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/notification/hipchat.py b/notification/hipchat.py index 24fde9ecb35..060babf08d8 100644 --- a/notification/hipchat.py +++ b/notification/hipchat.py @@ -96,6 +96,11 @@ def send_msg(module, token, room, msg_from, msg, msg_format='text', url = api + "?auth_token=%s" % (token) data = urllib.urlencode(params) + + if module.check_mode: + # In check mode, exit before actually sending the message + module.exit_json(changed=False) + response, info = fetch_url(module, url, data=data) if info['status'] == 200: return response.read() @@ -119,8 +124,8 @@ def main(): "purple", "gray", "random"]), msg_format=dict(default="text", choices=["text", "html"]), notify=dict(default=True, type='bool'), - validate_certs = dict(default='yes', type='bool'), - api = dict(default=MSG_URI), + validate_certs=dict(default='yes', type='bool'), + api=dict(default=MSG_URI), ), supports_check_mode=True )