From ed246a328f21ef844392ba377d1a5f65e4889191 Mon Sep 17 00:00:00 2001 From: Jean Prat Date: Wed, 31 Aug 2016 21:56:08 +0200 Subject: [PATCH] if user is empty, it is not converted to tuple when using host_all (#3038) --- lib/ansible/modules/database/mysql/mysql_user.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index 7f97a182068..4778a4eeac7 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -214,7 +214,7 @@ def get_mode(cursor): def user_exists(cursor, user, host, host_all): if host_all: - cursor.execute("SELECT count(*) FROM user WHERE user = %s", user) + cursor.execute("SELECT count(*) FROM user WHERE user = %s", ([user])) else: cursor.execute("SELECT count(*) FROM user WHERE user = %s AND host = %s", (user,host)) @@ -259,7 +259,7 @@ def user_mod(cursor, user, host, host_all, password, encrypted, new_priv, append # to simplify code, if we have a specific host and no host_all, we create # a list with just host and loop over that if host_all: - hostnames = user_get_hostnames(cursor, user) + hostnames = user_get_hostnames(cursor, [user]) else: hostnames = [host] @@ -349,7 +349,7 @@ def user_delete(cursor, user, host, host_all, check_mode): return True if host_all: - hostnames = user_get_hostnames(cursor, user) + hostnames = user_get_hostnames(cursor, [user]) for hostname in hostnames: cursor.execute("DROP USER %s@%s", (user, hostname))