From 5734838cd1fdc1a2be8e308c0d61d8dbe72a24f6 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 1 Dec 2014 07:15:27 -0800 Subject: [PATCH] Fix module traceback instead of returning an error --- lib/ansible/modules/database/mysql/mysql_user.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index 9bb1d7be4c7..e8461a05851 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -256,7 +256,7 @@ def privileges_get(cursor, user,host): for grant in grants: res = re.match("GRANT (.+) ON (.+) TO '.+'@'.+'( IDENTIFIED BY PASSWORD '.+')? ?(.*)", grant[0]) if res is None: - module.fail_json(msg="unable to parse the MySQL grant string") + raise InvalidPrivsError('unable to parse the MySQL grant string: %s' % grant[0]) privileges = res.group(1).split(", ") privileges = [ pick(x) for x in privileges] if "WITH GRANT OPTION" in res.group(4): @@ -485,6 +485,8 @@ def main(): changed = user_mod(cursor, user, host, password, priv, append_privs) except SQLParseError, e: module.fail_json(msg=str(e)) + except InvalidPrivsError, e: + module.mail_json(msg=str(e)) else: if password is None: module.fail_json(msg="password parameter required when adding a user")