mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-03 12:44:25 -07:00
Compare privileges from before and after manipulation
This commit is contained in:
parent
3670b2adc6
commit
5fb85e9dda
1 changed files with 18 additions and 1 deletions
|
@ -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)
|
privileges_revoke(cursor, user, host, db_table, revoke_privs, grant_option, maria_role)
|
||||||
if len(grant_privs) > 0:
|
if len(grant_privs) > 0:
|
||||||
privileges_grant(cursor, user, host, db_table, grant_privs, tls_requires, maria_role)
|
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:
|
if role:
|
||||||
continue
|
continue
|
||||||
|
@ -880,3 +885,15 @@ def get_impl(cursor):
|
||||||
else:
|
else:
|
||||||
from ansible_collections.community.mysql.plugins.module_utils.implementations.mysql import user as mysqluser
|
from ansible_collections.community.mysql.plugins.module_utils.implementations.mysql import user as mysqluser
|
||||||
impl = 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue