diff --git a/changelogs/fragments/52278-mysql_user-fix-regex b/changelogs/fragments/52278-mysql_user-fix-regex new file mode 100644 index 00000000000..24a6f39451e --- /dev/null +++ b/changelogs/fragments/52278-mysql_user-fix-regex @@ -0,0 +1,2 @@ +bugfixes: + - "mysql_user: fix the working but incorrect regex used to check the user privileges." diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index 12540007678..6205909de0e 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -444,7 +444,7 @@ def privileges_get(cursor, user, host): return x for grant in grants: - res = re.match("""GRANT (.+) ON (.+) TO (['`"]).*\\3@(['`"]).*\\4( IDENTIFIED BY PASSWORD (['`"]).+\5)? ?(.*)""", grant[0]) + res = re.match("""GRANT (.+) ON (.+) TO (['`"]).*\\3@(['`"]).*\\4( IDENTIFIED BY PASSWORD (['`"]).+\\6)? ?(.*)""", grant[0]) if res is None: raise InvalidPrivsError('unable to parse the MySQL grant string: %s' % grant[0]) privileges = res.group(1).split(", ")