From 2fce8010b4f6e1944b9734dc8df4235db1fa6bf3 Mon Sep 17 00:00:00 2001 From: mklassen Date: Fri, 9 Nov 2018 00:56:30 -0500 Subject: [PATCH] Added support for FUNCTION and PROCEDURE privileges to mysql_user (#23223) --- lib/ansible/modules/database/mysql/mysql_user.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index a796bb95960..fead25428fb 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -461,12 +461,20 @@ def privileges_unpack(priv, mode): for item in priv.strip().split('/'): pieces = item.strip().rsplit(':', 1) dbpriv = pieces[0].rsplit(".", 1) + + # Check for FUNCTION or PROCEDURE object types + parts = dbpriv[0].split(" ", 1) + object_type = '' + if len(parts) > 1 and (parts[0] == 'FUNCTION' or parts[0] == 'PROCEDURE'): + object_type = parts[0] + ' ' + dbpriv[0] = parts[1] + # Do not escape if privilege is for database or table, i.e. # neither quote *. nor .* for i, side in enumerate(dbpriv): if side.strip('`') != '*': dbpriv[i] = '%s%s%s' % (quote, side.strip('`'), quote) - pieces[0] = '.'.join(dbpriv) + pieces[0] = object_type + '.'.join(dbpriv) if '(' in pieces[1]: output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1].upper())