WIP: get user authentications plugins

This commit is contained in:
Laurent Indermuehle 2023-09-14 19:23:20 +02:00
parent bd944f7bf9
commit eb840f6ae4
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
2 changed files with 31 additions and 4 deletions

View file

@ -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

View file

@ -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