mysql_role: don't add members to a role when creating the role and "detach_members: true" is set (#367)

* mysql_role: don't add members to a role when creating the role and "detach_members: true" is set, add integration test

* add changelog fragment

* mysql_role: add author betanummeric

* Update changelogs/fragments/367-mysql_role-fix-deatch-members.yml

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

Co-authored-by: Felix Hamme <felix.hamme@ionos.com>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
betanummeric 2022-05-25 11:47:39 +02:00 committed by GitHub
parent 07a72865f7
commit ceda7662d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 0 deletions

View file

@ -15,3 +15,4 @@ nonexistent: user3
role0: role0
role1: role1
role2: role2
role3: role3

View file

@ -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 }}'