mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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:
parent
94ee25cace
commit
8d80ffd8ca
2 changed files with 5 additions and 3 deletions
|
@ -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 = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue