fix users with multiple schemas with ALL PRIVILEGES only showing first

This commit is contained in:
Laurent Indermuehle 2023-09-21 22:24:55 +02:00
parent 40f47f6828
commit 0bcfdb72ab
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
2 changed files with 18 additions and 12 deletions

View file

@ -552,17 +552,15 @@ def privileges_get(module, cursor, user, host, maria_role=False):
if "WITH GRANT OPTION" in res.group(7):
privileges.append('GRANT')
# Prevent to output 'ALL', 'ALL' because mysql 8 display all privileges
# with two lines as you can see in variable mysql8_all_privileges.
if (
'ALL' in privileges
and (['ALL'] in output.values() or ['ALL', 'GRANT'] in output.values())
):
continue
output.setdefault(db, []).extend(privileges)
return output
# Prevent to output 'ALL', 'ALL' because mysql 8 display all privileges
# with two lines as you can see in variable mysql8_all_privileges.
output_deduplicates = {}
for k, v in output.items():
output_deduplicates[k] = list(set(v))
return output_deduplicates
def normalize_col_grants(privileges):

View file

@ -15,7 +15,10 @@
# ================================ Prepare ==============================
- name: Mysql_info users_privs | Create databases
community.mysql.mysql_db:
name: users_privs_db
name:
- users_privs_db
- users_privs_db2
- users_privs_db3
state: present
- name: Mysql_info users_privs | Create tables
@ -74,7 +77,9 @@
- name: users_privs_multi
priv:
'mysql.*': 'SELECT'
'users_privs_db.*': 'SELECT'
'users_privs_db.*': 'ALL'
'users_privs_db2.*': 'ALL'
'users_privs_db3.*': 'ALL'
- name: users_privs_usage_only
priv:
'*.*': 'USAGE'
@ -194,7 +199,10 @@
- name: Mysql_info users_privs | Cleanup databases
community.mysql.mysql_db:
name: users_privs_db
name:
- users_privs_db
- users_privs_db2
- users_privs_db3
state: absent
- name: Mysql_info users_privs | Cleanup sql file for the procedure