diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index 7a54a65..ac6dfd3 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -114,7 +114,7 @@ def get_grants(cursor, user, host): def get_existing_authentication(cursor, user, host): - # Return the plugin and auth_string if there is exactly one distinct existing plugin and auth_string. + # Return the plugin and plugin_auth_string if there is exactly one distinct existing plugin and plugin_auth_string. if get_server_type(cursor) == 'mariadb': # before MariaDB 10.2.19 and 10.3.11, "password" and "authentication_string" can differ @@ -132,10 +132,10 @@ def get_existing_authentication(cursor, user, host): rows = cursor.fetchall() if isinstance(rows[0], tuple): - return {'plugin': rows[0][0], 'auth_string': rows[0][1]} + return {'plugin': rows[0][0], 'plugin_auth_string': rows[0][1]} if isinstance(rows[0], dict): - return {'plugin': rows[0].get('plugin'), 'auth_string': rows[0].get('auth')} + return {'plugin': rows[0].get('plugin'), 'plugin_auth_string': rows[0].get('auth')} return None @@ -160,7 +160,7 @@ def user_add(cursor, user, host, host_all, password, encrypted, existing_auth = get_existing_authentication(cursor, user, host) if existing_auth: plugin = existing_auth['plugin'] - plugin_hash_string = existing_auth['auth_string'] + plugin_hash_string = existing_auth['plugin_auth_string'] password = None used_existing_password = True if password and encrypted: @@ -308,7 +308,7 @@ def user_mod(cursor, user, host, host_all, password, encrypted, if plugin_auth_string and current_plugin[1] != plugin_auth_string: # this case can cause more updates than expected, - # as plugin can hash auth_string in any way it wants + # as plugin can hash plugin_auth_string in any way it wants # and there's no way to figure it out for # a check, so I prefer to update more often than never update = True diff --git a/plugins/modules/mysql_info.py b/plugins/modules/mysql_info.py index 777eeb4..45cb608 100644 --- a/plugins/modules/mysql_info.py +++ b/plugins/modules/mysql_info.py @@ -138,7 +138,8 @@ EXAMPLES = r''' name: "{{ item.name }}" host: "{{ item.host }}" plugin: "{{ item.plugin | default(omit) }}" - plugin_auth_string: "{{ item.auth_string | 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) }}" @@ -222,7 +223,7 @@ users_privs: returned: if not excluded by filter type: dict sample: - - { "auth_string": '*1234567', + - { "plugin_auth_string": '*1234567', "name": "user1", "host": "host.com", "plugin": "mysql_native_password", 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 45ccc6f..fa8d418 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 @@ -48,8 +48,8 @@ community.mysql.mysql_user: name: "{{ item.name }}" host: "users_privs.com" - password: '*6C387FC3893DBA1E3BA155E74754DA6682D04747' - encrypted: true + plugin: "mysql_native_password" + plugin_hash_string: '*6C387FC3893DBA1E3BA155E74754DA6682D04747' priv: "{{ item.priv }}" resource_limits: "{{ item.resource_limits | default(omit) }}" state: present @@ -107,8 +107,6 @@ community.mysql.mysql_user: name: "{{ item.name }}" host: "users_privs.com" - password: "{{ item.password | default(omit) }}" - encrypted: true plugin: "{{ item.plugin | default(omit) }}" plugin_auth_string: "{{ item.plugin_auth_string | default(omit) }}" plugin_hash_string: "{{ item.plugin_hash_string | default(omit) }}" @@ -130,8 +128,6 @@ community.mysql.mysql_user: name: "{{ item.name }}" host: "users_privs.com" - password: "{{ item.password | default(omit) }}" - encrypted: true plugin: "{{ item.plugin | default(omit) }}" plugin_auth_string: "{{ item.plugin_auth_string | default(omit) }}" plugin_hash_string: "{{ item.plugin_hash_string | default(omit) }}" @@ -163,7 +159,8 @@ name: "{{ item.name }}" host: "{{ item.host }}" plugin: "{{ item.plugin | default(omit) }}" - plugin_auth_string: "{{ item.auth_string | 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) }}"