mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-08 19:50:31 -07:00
WIP: get user authentications plugins
This commit is contained in:
parent
bd944f7bf9
commit
eb840f6ae4
2 changed files with 31 additions and 4 deletions
|
@ -251,6 +251,7 @@ from ansible_collections.community.mysql.plugins.module_utils.mysql import (
|
||||||
from ansible_collections.community.mysql.plugins.module_utils.user import (
|
from ansible_collections.community.mysql.plugins.module_utils.user import (
|
||||||
privileges_get,
|
privileges_get,
|
||||||
get_resource_limits,
|
get_resource_limits,
|
||||||
|
get_existing_authentication,
|
||||||
)
|
)
|
||||||
from ansible.module_utils.six import iteritems
|
from ansible.module_utils.six import iteritems
|
||||||
from ansible.module_utils._text import to_native
|
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)
|
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)
|
copy_ressource_limits = dict.copy(resource_limits)
|
||||||
output_dict = {
|
output_dict = {
|
||||||
'user': user,
|
'user': user,
|
||||||
'host': host,
|
'host': host,
|
||||||
|
'password': 'msandbox',
|
||||||
'privs': '/'.join(priv_string),
|
'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
|
# Prevent returning a resource limit if there is no value
|
||||||
|
|
|
@ -45,7 +45,11 @@
|
||||||
community.mysql.mysql_user:
|
community.mysql.mysql_user:
|
||||||
name: "{{ item.user }}"
|
name: "{{ item.user }}"
|
||||||
host: "users_privs.com"
|
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 }}"
|
priv: "{{ item.privs }}"
|
||||||
resource_limits: "{{ item.resource_limits | default(omit) }}"
|
resource_limits: "{{ item.resource_limits | default(omit) }}"
|
||||||
state: present
|
state: present
|
||||||
|
@ -53,20 +57,24 @@
|
||||||
- user: users_privs_adm
|
- user: users_privs_adm
|
||||||
privs:
|
privs:
|
||||||
'*.*': 'ALL,GRANT'
|
'*.*': 'ALL,GRANT'
|
||||||
|
password: 'msandbox'
|
||||||
- user: users_privs_schema
|
- user: users_privs_schema
|
||||||
privs:
|
privs:
|
||||||
'users_privs_db.*': 'SELECT,INSERT,UPDATE,DELETE'
|
'users_privs_db.*': 'SELECT,INSERT,UPDATE,DELETE'
|
||||||
|
password: 'msandbox'
|
||||||
- user: users_privs_table
|
- user: users_privs_table
|
||||||
privs:
|
privs:
|
||||||
'users_privs_db.t1': 'SELECT,INSERT,UPDATE'
|
'users_privs_db.t1': 'SELECT,INSERT,UPDATE'
|
||||||
- user: users_privs_col
|
- user: users_privs_col
|
||||||
privs:
|
privs:
|
||||||
'users_privs_db.t1': 'SELECT (id)'
|
'users_privs_db.t1': 'SELECT (id)'
|
||||||
|
password: 'msandbox'
|
||||||
resource_limits:
|
resource_limits:
|
||||||
MAX_USER_CONNECTIONS: 100
|
MAX_USER_CONNECTIONS: 100
|
||||||
- user: users_privs_proc
|
- user: users_privs_proc
|
||||||
privs:
|
privs:
|
||||||
'PROCEDURE users_privs_db.get_all_items': 'EXECUTE'
|
'PROCEDURE users_privs_db.get_all_items': 'EXECUTE'
|
||||||
|
password: 'msandbox'
|
||||||
resource_limits:
|
resource_limits:
|
||||||
MAX_USER_CONNECTIONS: 2
|
MAX_USER_CONNECTIONS: 2
|
||||||
MAX_CONNECTIONS_PER_HOUR: 60
|
MAX_CONNECTIONS_PER_HOUR: 60
|
||||||
|
@ -74,6 +82,16 @@
|
||||||
privs:
|
privs:
|
||||||
'mysql.*': 'SELECT'
|
'mysql.*': 'SELECT'
|
||||||
'users_privs_db.*': '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 ==============================
|
# ================================== Tests ==============================
|
||||||
|
|
||||||
|
@ -89,8 +107,12 @@
|
||||||
community.mysql.mysql_user:
|
community.mysql.mysql_user:
|
||||||
name: "{{ item.user }}"
|
name: "{{ item.user }}"
|
||||||
host: "{{ item.host }}"
|
host: "{{ item.host }}"
|
||||||
password: "{{ item.password }}"
|
password: "{{ item.password | default(omit) }}"
|
||||||
encrypted: true
|
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) }}"
|
priv: "{{ item.priv | default(omit) }}"
|
||||||
resource_limits: "{{ item.resource_limits | default(omit) }}"
|
resource_limits: "{{ item.resource_limits | default(omit) }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
Loading…
Add table
Reference in a new issue