attempt to use privileges_get

This commit is contained in:
Laurent Indermuehle 2023-09-13 18:01:59 +02:00
parent 7f2f141275
commit 028089da6d
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
2 changed files with 18 additions and 12 deletions

View file

@ -249,7 +249,7 @@ from ansible_collections.community.mysql.plugins.module_utils.mysql import (
get_server_version,
)
from ansible_collections.community.mysql.plugins.module_utils.user import (
get_grants,
privileges_get,
)
from ansible.module_utils.six import iteritems
from ansible.module_utils._text import to_native
@ -510,15 +510,20 @@ class MySQL_Info(object):
h = line['Host']
key = u + '_' + h
privs = get_grants(self.module, self.cursor, u, h)
user_priv = privileges_get(self.module, self.cursor, u, h)
if not privs:
self.module.warn(
'Fail to get privileges for user %s on host %s.' % (u, h))
privs = {}
if not user_priv:
self.module.warn("No privileges found for %s on host %s" % (u, h))
continue
# if not privs:
# self.module.warn(
# 'Fail to get privileges for user %s on host %s.' % (u, h))
# privs = {}
self.info['users_privs'][key] = {
'user': u, 'host': h, 'privs': privs}
'user': u, 'host': h, 'privs': user_priv}
def __get_databases(self, exclude_fields, return_empty_dbs):
"""Get info about databases."""