mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-06 10:40:36 -07:00
mysql_role - don't add members to a role when creating the role and detach_members true is set (#372)
Co-authored-by: betanummeric <40263343+betanummeric@users.noreply.github.com>
This commit is contained in:
parent
e34cfba109
commit
46dc308e28
4 changed files with 33 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "mysql_role - don't add members to a role when creating the role and ``detach_members: true`` is set (https://github.com/ansible-collections/community.mysql/pull/367)."
|
|
@ -119,6 +119,7 @@ seealso:
|
|||
|
||||
author:
|
||||
- Andrew Klychkov (@Andersson007)
|
||||
- Felix Hamme (@betanummeric)
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.mysql.mysql
|
||||
|
@ -1006,6 +1007,8 @@ def main():
|
|||
try:
|
||||
if state == 'present':
|
||||
if not role.exists:
|
||||
if detach_members:
|
||||
members = None # avoid adding unwanted members
|
||||
changed = role.add(members, priv, module.check_mode, admin,
|
||||
set_default_role_all)
|
||||
|
||||
|
|
|
@ -14,3 +14,4 @@ nonexistent: user3
|
|||
|
||||
role0: role0
|
||||
role1: role1
|
||||
role3: role3
|
||||
|
|
|
@ -1248,6 +1248,32 @@
|
|||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: '"detach" users when creating a new role'
|
||||
<<: *task_params
|
||||
mysql_role:
|
||||
<<: *mysql_params
|
||||
name: '{{ role3 }}'
|
||||
state: present
|
||||
detach_members: yes
|
||||
members:
|
||||
- '{{ user1 }}@localhost'
|
||||
|
||||
- name: Check the role was created
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Check grants
|
||||
<<: *task_params
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
query: "SHOW GRANTS FOR {{ user1 }}@localhost"
|
||||
|
||||
- name: asssert detach_members did not add a user to the role
|
||||
assert:
|
||||
that:
|
||||
- "'{{ role3 }}' not in result.query_result.0.0['Grants for {{ user1 }}@localhost']"
|
||||
|
||||
# ##########
|
||||
# Test privs
|
||||
# ##########
|
||||
|
@ -1561,3 +1587,4 @@
|
|||
loop:
|
||||
- '{{ role0 }}'
|
||||
- test
|
||||
- '{{ role3 }}'
|
||||
|
|
Loading…
Add table
Reference in a new issue