mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-29 01:11:46 -07:00
mysql_role, mysql_user: when subtract_privileges, don't grant unwanted privileges and don't revoke USAGE implicitly
This commit is contained in:
parent
47b2ba5b88
commit
52eb368e30
3 changed files with 8 additions and 4 deletions
|
@ -1034,7 +1034,7 @@ def main():
|
|||
module.fail_json(msg=to_native(e))
|
||||
|
||||
try:
|
||||
priv = privileges_unpack(priv, mode)
|
||||
priv = privileges_unpack(priv, mode, ensure_usage=not subtract_privs)
|
||||
except Exception as e:
|
||||
module.fail_json(msg='Invalid privileges string: %s' % to_native(e))
|
||||
|
||||
|
@ -1063,6 +1063,8 @@ def main():
|
|||
try:
|
||||
if state == 'present':
|
||||
if not role.exists:
|
||||
if subtract_privs:
|
||||
priv = None # avoid granting unwanted privileges
|
||||
changed = role.add(members, priv, module.check_mode, admin,
|
||||
set_default_role_all)
|
||||
|
||||
|
|
|
@ -443,7 +443,7 @@ def main():
|
|||
mode = get_mode(cursor)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=to_native(e))
|
||||
priv = privileges_unpack(priv, mode)
|
||||
priv = privileges_unpack(priv, mode, ensure_usage=not subtract_privs)
|
||||
|
||||
if state == "present":
|
||||
if user_exists(cursor, user, host, host_all):
|
||||
|
@ -463,6 +463,8 @@ def main():
|
|||
if host_all:
|
||||
module.fail_json(msg="host_all parameter cannot be used when adding a user")
|
||||
try:
|
||||
if subtract_privs:
|
||||
priv = None # avoid granting unwanted privileges
|
||||
changed = user_add(cursor, user, host, host_all, password, encrypted,
|
||||
plugin, plugin_hash_string, plugin_auth_string,
|
||||
priv, tls_requires, module.check_mode)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue