Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql_user: fix cursor-related host_all arguments conversion string formatting error #490

Merged
merged 2 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/490-mysql_user_fix_cursor_errors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- mysql_user - fix ``host_all`` arguments conversion string formatting error (https://github.com/ansible/ansible/issues/29644).
6 changes: 3 additions & 3 deletions plugins/modules/database/mysql/mysql_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,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))

Expand Down Expand Up @@ -539,7 +539,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))
Expand All @@ -550,7 +550,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 = []

Expand Down