diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index bc874e1..3e56992 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -385,7 +385,12 @@ def user_mod(cursor, user, host, host_all, password, encrypted, privileges_revoke(cursor, user, host, db_table, revoke_privs, grant_option, maria_role) if len(grant_privs) > 0: privileges_grant(cursor, user, host, db_table, grant_privs, tls_requires, maria_role) - changed = True + + # after privilege manipulation, compare privileges from before and now + changed = changed or not privileges_equal( + curr_priv, + privileges_get(cursor, user, host, maria_role) + ) if role: continue @@ -880,3 +885,15 @@ def get_impl(cursor): else: from ansible_collections.community.mysql.plugins.module_utils.implementations.mysql import user as mysqluser impl = mysqluser + + +def privileges_equal(before_privs, after_privs): + """Compare 2 priv dicts + + Args: + before_privs (dict): contains privileges, built with privileges_get() + after_privs (dict): contains privileges, built with privileges_get() + + Returns: True, if equal, False otherwise. + """ + return before_privs == after_privs