Fix tls_requires data structure inconsistencies between modules

This commit is contained in:
Laurent Indermuehle 2024-04-11 11:17:04 +02:00
parent 502bf58df1
commit 5460dec642
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
2 changed files with 6 additions and 4 deletions

View file

@ -102,14 +102,15 @@ def get_tls_requires(cursor, user, host):
if isinstance(res, dict):
res = list(res.values())
if not res:
# When user don't require SSL, res value is: ('', '', '', '')
if not any(res):
return None
if res[0] == 'ANY':
return {'SSL': ''}
return 'SSL'
if res[0] == 'X509':
return {'X509': ''}
return 'X509'
if res[1]:
tls_requires['CIPHER'] = res[1]

View file

@ -301,6 +301,7 @@ from ansible_collections.community.mysql.plugins.module_utils.user import (
get_resource_limits,
get_existing_authentication,
get_tls_requires,
sanitize_requires,
)
from ansible.module_utils.six import iteritems
from ansible.module_utils._text import to_native
@ -612,7 +613,7 @@ class MySQL_Info(object):
'host': host,
'priv': '/'.join(priv_string),
'resource_limits': copy_ressource_limits,
'tls_requires': tls_requires,
'tls_requires': sanitize_requires(tls_requires),
}
# Prevent returning a resource limit if empty