diff --git a/plugins/modules/mysql_info.py b/plugins/modules/mysql_info.py index 1a42b33..70ab99f 100644 --- a/plugins/modules/mysql_info.py +++ b/plugins/modules/mysql_info.py @@ -251,6 +251,7 @@ from ansible_collections.community.mysql.plugins.module_utils.mysql import ( from ansible_collections.community.mysql.plugins.module_utils.user import ( privileges_get, get_resource_limits, + get_existing_authentication, ) from ansible.module_utils.six import iteritems from ansible.module_utils._text import to_native @@ -552,12 +553,16 @@ class MySQL_Info(object): resource_limits = get_resource_limits(self.module, self.cursor, user, host) + authentications = get_existing_authentication(self.cursor, user, host) + copy_ressource_limits = dict.copy(resource_limits) output_dict = { 'user': user, 'host': host, + 'password': 'msandbox', 'privs': '/'.join(priv_string), - 'resource_limits': copy_ressource_limits + 'resource_limits': copy_ressource_limits, + 'authentications': authentications } # Prevent returning a resource limit if there is no value diff --git a/tests/integration/targets/test_mysql_info/tasks/filter_users_privs.yml b/tests/integration/targets/test_mysql_info/tasks/filter_users_privs.yml index a8e978d..8f8434d 100644 --- a/tests/integration/targets/test_mysql_info/tasks/filter_users_privs.yml +++ b/tests/integration/targets/test_mysql_info/tasks/filter_users_privs.yml @@ -45,7 +45,11 @@ community.mysql.mysql_user: name: "{{ item.user }}" host: "users_privs.com" - password: "msandbox" + password: "{{ item.password | default(omit) }}" + plugin: "{{ item.plugin | default(omit) }}" + plugin_auth_string: "{{ item.plugin_auth_string | default(omit) }}" + plugin_hash_string: "{{ item.plugin_hash_string | default(omit) }}" + tls_require: "{{ item.tls_require | default(omit) }}" priv: "{{ item.privs }}" resource_limits: "{{ item.resource_limits | default(omit) }}" state: present @@ -53,20 +57,24 @@ - user: users_privs_adm privs: '*.*': 'ALL,GRANT' + password: 'msandbox' - user: users_privs_schema privs: 'users_privs_db.*': 'SELECT,INSERT,UPDATE,DELETE' + password: 'msandbox' - user: users_privs_table privs: 'users_privs_db.t1': 'SELECT,INSERT,UPDATE' - user: users_privs_col privs: 'users_privs_db.t1': 'SELECT (id)' + password: 'msandbox' resource_limits: MAX_USER_CONNECTIONS: 100 - user: users_privs_proc privs: 'PROCEDURE users_privs_db.get_all_items': 'EXECUTE' + password: 'msandbox' resource_limits: MAX_USER_CONNECTIONS: 2 MAX_CONNECTIONS_PER_HOUR: 60 @@ -74,6 +82,16 @@ privs: 'mysql.*': 'SELECT' 'users_privs_db.*': 'SELECT' + password: 'msandbox' + # - user: users_privs_socket # Only for MariaDB + # privs: + # '*.*': 'ALL' + # plugin: 'unix_socket' + # - user: users_privs_socket # Only for MySQL + # privs: + # '*.*': 'ALL' + # plugin_auth_string: 'msandbox' + # plugin: 'sha256_password' # ================================== Tests ============================== @@ -89,8 +107,12 @@ community.mysql.mysql_user: name: "{{ item.user }}" host: "{{ item.host }}" - password: "{{ item.password }}" - encrypted: true + password: "{{ item.password | default(omit) }}" + encrypted: "{{ item.encrypted | default(omit) }}" + plugin: "{{ item.plugin | default(omit) }}" + plugin_auth_string: "{{ item.plugin_auth_string | default(omit) }}" + plugin_hash_string: "{{ item.plugin_hash_string | default(omit) }}" + tls_require: "{{ item.tls_require | default(omit) }}" priv: "{{ item.priv | default(omit) }}" resource_limits: "{{ item.resource_limits | default(omit) }}" state: present