From 5460dec642d26b445a5d1e858545dbabc466264a Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Thu, 11 Apr 2024 11:17:04 +0200 Subject: [PATCH] Fix tls_requires data structure inconsistencies between modules --- plugins/module_utils/user.py | 7 ++++--- plugins/modules/mysql_info.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index 7833859..28174f8 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -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] diff --git a/plugins/modules/mysql_info.py b/plugins/modules/mysql_info.py index 86ec7cc..10f4548 100644 --- a/plugins/modules/mysql_info.py +++ b/plugins/modules/mysql_info.py @@ -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