mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
mysql_user: fix cursor-related host_all arguments conversion string formatting error (#490)
* mysql_user: fix cursor-related host_all arguments conversion string formatting error * add changelog fragment
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- mysql_user - fix ``host_all`` arguments conversion string formatting error (https://github.com/ansible/ansible/issues/29644).
|
||||||
@@ -340,7 +340,7 @@ def get_mode(cursor):
|
|||||||
|
|
||||||
def user_exists(cursor, user, host, host_all):
|
def user_exists(cursor, user, host, host_all):
|
||||||
if host_all:
|
if host_all:
|
||||||
cursor.execute("SELECT count(*) FROM mysql.user WHERE user = %s", ([user]))
|
cursor.execute("SELECT count(*) FROM mysql.user WHERE user = %s", (user,))
|
||||||
else:
|
else:
|
||||||
cursor.execute("SELECT count(*) FROM mysql.user WHERE user = %s AND host = %s", (user, host))
|
cursor.execute("SELECT count(*) FROM mysql.user WHERE user = %s AND host = %s", (user, host))
|
||||||
|
|
||||||
@@ -543,7 +543,7 @@ def user_delete(cursor, user, host, host_all, check_mode):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if host_all:
|
if host_all:
|
||||||
hostnames = user_get_hostnames(cursor, [user])
|
hostnames = user_get_hostnames(cursor, user)
|
||||||
|
|
||||||
for hostname in hostnames:
|
for hostname in hostnames:
|
||||||
cursor.execute("DROP USER %s@%s", (user, hostname))
|
cursor.execute("DROP USER %s@%s", (user, hostname))
|
||||||
@@ -554,7 +554,7 @@ def user_delete(cursor, user, host, host_all, check_mode):
|
|||||||
|
|
||||||
|
|
||||||
def user_get_hostnames(cursor, user):
|
def user_get_hostnames(cursor, user):
|
||||||
cursor.execute("SELECT Host FROM mysql.user WHERE user = %s", user)
|
cursor.execute("SELECT Host FROM mysql.user WHERE user = %s", (user,))
|
||||||
hostnames_raw = cursor.fetchall()
|
hostnames_raw = cursor.fetchall()
|
||||||
hostnames = []
|
hostnames = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user