From 29885d12430eea8620e051550c215c84b6033179 Mon Sep 17 00:00:00 2001 From: Felix Hamme Date: Thu, 28 Apr 2022 11:41:40 +0200 Subject: [PATCH] mysql_user and mysql_role: fix granting privileges when only the GRANT OPTION needs to be added --- plugins/module_utils/user.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index 7497cf5..07117a8 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -331,6 +331,9 @@ def user_mod(cursor, user, host, host_all, password, encrypted, # and revoke existing privileges that were not requested. grant_privs = list(set(new_priv[db_table]) - set(curr_priv[db_table])) revoke_privs = list(set(curr_priv[db_table]) - set(new_priv[db_table])) + if grant_privs == ['GRANT']: + # add the existing privileges because 'WITH GRANT OPTION' cannot stand alone + grant_privs.extend(curr_priv[db_table]) if len(grant_privs) + len(revoke_privs) > 0: msg = "Privileges updated"