1
0
Fork 0
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:
Andrew Klychkov 2020-06-15 09:12:20 +03:00 committed by GitHub
parent 94ee25cace
commit 8d80ffd8ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- mysql_user - fix ``host_all`` arguments conversion string formatting error (https://github.com/ansible/ansible/issues/29644).

View file

@ -340,7 +340,7 @@ def get_mode(cursor):
def user_exists(cursor, user, host, 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:
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
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))
@ -554,7 +554,7 @@ def user_delete(cursor, user, host, host_all, check_mode):
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 = []