mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-22 10:21:29 -07:00
Merge branch 'main' into lie_tests_using_containers
This commit is contained in:
commit
4a5220105b
22 changed files with 150 additions and 60 deletions
|
@ -6,6 +6,33 @@ Community MySQL Collection Release Notes
|
||||||
|
|
||||||
This changelog describes changes after version 2.0.0.
|
This changelog describes changes after version 2.0.0.
|
||||||
|
|
||||||
|
v3.6.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This is the minor release of the ``community.mysql`` collection.
|
||||||
|
This changelog contains all changes to the modules and plugins in this collection
|
||||||
|
that have been made after the previous release.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- mysql_info - add ``connector_name`` and ``connector_version`` to returned values (https://github.com/ansible-collections/community.mysql/pull/497).
|
||||||
|
- mysql_role - enable auto_commit to avoid MySQL metadata table lock (https://github.com/ansible-collections/community.mysql/issues/479).
|
||||||
|
- mysql_user - add plugin_auth_string as optional parameter to use a specific pam service if pam/auth_pam plugin is used (https://github.com/ansible-collections/community.mysql/pull/445).
|
||||||
|
- mysql_user - add the ``session_vars`` argument to set session variables at the beginning of module execution (https://github.com/ansible-collections/community.mysql/issues/478).
|
||||||
|
- mysql_user - display a more informative invalid privilege exception. Changes the exception handling of the granting permission logic to show the query executed , params and the exception message granting privileges fails` (https://github.com/ansible-collections/community.mysql/issues/465).
|
||||||
|
- mysql_user - enable auto_commit to avoid MySQL metadata table lock (https://github.com/ansible-collections/community.mysql/issues/479).
|
||||||
|
- setup_mysql - update MySQL tarball URL (https://github.com/ansible-collections/community.mysql/pull/491).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- mysql_user - when revoke privs consists only of ``GRANT``, a 2nd revoke query is executed with empty privs to revoke that ended in an SQL exception (https://github.com/ansible-collections/community.mysql/pull/503).
|
||||||
|
- mysql_variables - add uppercase character pattern to regex to allow GLOBAL variables containing uppercase characters. This recognizes variable names used in Galera, for example, ``wsrep_OSU_method``, which breaks the normal pattern of all lowercase characters (https://github.com/ansible-collections/community.mysql/pull/501).
|
||||||
|
|
||||||
v3.5.1
|
v3.5.1
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
|
@ -261,3 +261,42 @@ releases:
|
||||||
- 3.5.1.yml
|
- 3.5.1.yml
|
||||||
- 438-fix-privilege-changing-everytime.yml
|
- 438-fix-privilege-changing-everytime.yml
|
||||||
release_date: '2022-09-09'
|
release_date: '2022-09-09'
|
||||||
|
3.6.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- mysql_user - when revoke privs consists only of ``GRANT``, a 2nd revoke query
|
||||||
|
is executed with empty privs to revoke that ended in an SQL exception (https://github.com/ansible-collections/community.mysql/pull/503).
|
||||||
|
- mysql_variables - add uppercase character pattern to regex to allow GLOBAL
|
||||||
|
variables containing uppercase characters. This recognizes variable names
|
||||||
|
used in Galera, for example, ``wsrep_OSU_method``, which breaks the normal
|
||||||
|
pattern of all lowercase characters (https://github.com/ansible-collections/community.mysql/pull/501).
|
||||||
|
minor_changes:
|
||||||
|
- mysql_info - add ``connector_name`` and ``connector_version`` to returned
|
||||||
|
values (https://github.com/ansible-collections/community.mysql/pull/497).
|
||||||
|
- mysql_role - enable auto_commit to avoid MySQL metadata table lock (https://github.com/ansible-collections/community.mysql/issues/479).
|
||||||
|
- mysql_user - add plugin_auth_string as optional parameter to use a specific
|
||||||
|
pam service if pam/auth_pam plugin is used (https://github.com/ansible-collections/community.mysql/pull/445).
|
||||||
|
- mysql_user - add the ``session_vars`` argument to set session variables at
|
||||||
|
the beginning of module execution (https://github.com/ansible-collections/community.mysql/issues/478).
|
||||||
|
- mysql_user - display a more informative invalid privilege exception. Changes
|
||||||
|
the exception handling of the granting permission logic to show the query
|
||||||
|
executed , params and the exception message granting privileges fails` (https://github.com/ansible-collections/community.mysql/issues/465).
|
||||||
|
- mysql_user - enable auto_commit to avoid MySQL metadata table lock (https://github.com/ansible-collections/community.mysql/issues/479).
|
||||||
|
- setup_mysql - update MySQL tarball URL (https://github.com/ansible-collections/community.mysql/pull/491).
|
||||||
|
release_summary: 'This is the minor release of the ``community.mysql`` collection.
|
||||||
|
|
||||||
|
This changelog contains all changes to the modules and plugins in this collection
|
||||||
|
|
||||||
|
that have been made after the previous release.'
|
||||||
|
fragments:
|
||||||
|
- 0_mysql_user_session_vars.yml
|
||||||
|
- 3.6.0.yml
|
||||||
|
- 445_add_service_name_to_plugin_pam_auth_pam_usage.yml
|
||||||
|
- 465-display_more_informative_invalid_priv_exceptiion.yml
|
||||||
|
- 479_enable_auto_commit.yml
|
||||||
|
- 479_enable_auto_commit_part2.yml
|
||||||
|
- 491_fix_download_url.yaml
|
||||||
|
- 497_mysql_info_returns_connector_name_and_version.yml
|
||||||
|
- 503-fix-revoke-grant-only.yml
|
||||||
|
- mysql_variables_allow_uppercase_identifiers.yml
|
||||||
|
release_date: '2023-02-08'
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
minor_changes:
|
|
||||||
- mysql_user - add the ``session_vars`` argument to set session variables at the beginning of module execution (https://github.com/ansible-collections/community.mysql/issues/478).
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- mysql module utils - change deprecated connection parameters ``passwd`` and ``db`` to ``password`` and ``database`` (https://github.com/ansible-collections/community.mysql/pull/177).
|
|
@ -1,3 +0,0 @@
|
||||||
---
|
|
||||||
minor_changes:
|
|
||||||
- mysql_user - add plugin_auth_string as optional parameter to use a specific pam service if pam/auth_pam plugin is used (https://github.com/ansible-collections/community.mysql/pull/445).
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
minor_changes:
|
|
||||||
- mysql_user - display a more informative invalid privilege exception.
|
|
||||||
Changes the exception handling of the granting permission logic to show the query executed , params
|
|
||||||
and the exception message granting privileges fails` (https://github.com/ansible-collections/community.mysql/issues/465).
|
|
|
@ -1,3 +0,0 @@
|
||||||
---
|
|
||||||
minor_changes:
|
|
||||||
- mysql_user - enable auto_commit to avoid MySQL metadata table lock (https://github.com/ansible-collections/community.mysql/issues/479).
|
|
|
@ -1,3 +0,0 @@
|
||||||
---
|
|
||||||
minor_changes:
|
|
||||||
- setup_mysql - update MySQL tarball URL (https://github.com/ansible-collections/community.mysql/pull/491).
|
|
|
@ -1,3 +0,0 @@
|
||||||
---
|
|
||||||
minor_changes:
|
|
||||||
- mysql_info - add ``connector_name`` and ``connector_version`` to returned values (https://github.com/ansible-collections/community.mysql/pull/497).
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace: community
|
namespace: community
|
||||||
name: mysql
|
name: mysql
|
||||||
version: 3.5.1
|
version: 3.6.0
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- Ansible community
|
- Ansible community
|
||||||
|
|
|
@ -122,7 +122,7 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
|
||||||
if login_user is not None:
|
if login_user is not None:
|
||||||
config['user'] = login_user
|
config['user'] = login_user
|
||||||
if login_password is not None:
|
if login_password is not None:
|
||||||
config['passwd'] = login_password
|
config['password'] = login_password
|
||||||
if ssl_cert is not None:
|
if ssl_cert is not None:
|
||||||
config['ssl']['cert'] = ssl_cert
|
config['ssl']['cert'] = ssl_cert
|
||||||
if ssl_key is not None:
|
if ssl_key is not None:
|
||||||
|
@ -130,7 +130,7 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
|
||||||
if ssl_ca is not None:
|
if ssl_ca is not None:
|
||||||
config['ssl']['ca'] = ssl_ca
|
config['ssl']['ca'] = ssl_ca
|
||||||
if db is not None:
|
if db is not None:
|
||||||
config['db'] = db
|
config['database'] = db
|
||||||
if connect_timeout is not None:
|
if connect_timeout is not None:
|
||||||
config['connect_timeout'] = connect_timeout
|
config['connect_timeout'] = connect_timeout
|
||||||
if check_hostname is not None:
|
if check_hostname is not None:
|
||||||
|
|
|
@ -692,6 +692,8 @@ def privileges_revoke(cursor, user, host, db_table, priv, grant_option, maria_ro
|
||||||
query = ' '.join(query)
|
query = ' '.join(query)
|
||||||
cursor.execute(query, (user, host))
|
cursor.execute(query, (user, host))
|
||||||
priv_string = ",".join([p for p in priv if p not in ('GRANT', )])
|
priv_string = ",".join([p for p in priv if p not in ('GRANT', )])
|
||||||
|
|
||||||
|
if priv_string != "":
|
||||||
query = ["REVOKE %s ON %s" % (priv_string, db_table)]
|
query = ["REVOKE %s ON %s" % (priv_string, db_table)]
|
||||||
|
|
||||||
if not maria_role:
|
if not maria_role:
|
||||||
|
|
|
@ -292,7 +292,6 @@ from ansible_collections.community.mysql.plugins.module_utils.mysql import (
|
||||||
mysql_common_argument_spec,
|
mysql_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
from ansible_collections.community.mysql.plugins.module_utils.version import LooseVersion
|
|
||||||
|
|
||||||
executed_queries = []
|
executed_queries = []
|
||||||
|
|
||||||
|
|
|
@ -1008,7 +1008,8 @@ def main():
|
||||||
cursor, db_conn = mysql_connect(module, 'root', '', config_file,
|
cursor, db_conn = mysql_connect(module, 'root', '', config_file,
|
||||||
ssl_cert, ssl_key, ssl_ca, db,
|
ssl_cert, ssl_key, ssl_ca, db,
|
||||||
connect_timeout=connect_timeout,
|
connect_timeout=connect_timeout,
|
||||||
check_hostname=check_hostname)
|
check_hostname=check_hostname,
|
||||||
|
autocommit=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1016,7 +1017,8 @@ def main():
|
||||||
cursor, db_conn = mysql_connect(module, login_user, login_password,
|
cursor, db_conn = mysql_connect(module, login_user, login_password,
|
||||||
config_file, ssl_cert, ssl_key,
|
config_file, ssl_cert, ssl_key,
|
||||||
ssl_ca, db, connect_timeout=connect_timeout,
|
ssl_ca, db, connect_timeout=connect_timeout,
|
||||||
check_hostname=check_hostname)
|
check_hostname=check_hostname,
|
||||||
|
autocommit=True)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
module.fail_json(msg='unable to connect to database, '
|
module.fail_json(msg='unable to connect to database, '
|
||||||
|
|
|
@ -199,7 +199,7 @@ def main():
|
||||||
|
|
||||||
if mysqlvar is None:
|
if mysqlvar is None:
|
||||||
module.fail_json(msg="Cannot run without variable to operate with")
|
module.fail_json(msg="Cannot run without variable to operate with")
|
||||||
if match('^[0-9a-z_.]+$', mysqlvar) is None:
|
if match('^[0-9A-Za-z_.]+$', mysqlvar) is None:
|
||||||
module.fail_json(msg="invalid variable name \"%s\"" % mysqlvar)
|
module.fail_json(msg="invalid variable name \"%s\"" % mysqlvar)
|
||||||
if mysql_driver is None:
|
if mysql_driver is None:
|
||||||
module.fail_json(msg=mysql_driver_fail_msg)
|
module.fail_json(msg=mysql_driver_fail_msg)
|
||||||
|
|
|
@ -240,3 +240,5 @@
|
||||||
|
|
||||||
# https://github.com/ansible-collections/community.mysql/issues/231
|
# https://github.com/ansible-collections/community.mysql/issues/231
|
||||||
- include: test_user_grants_with_roles_applied.yml
|
- include: test_user_grants_with_roles_applied.yml
|
||||||
|
|
||||||
|
- include: revoke_only_grant.yml
|
|
@ -0,0 +1,58 @@
|
||||||
|
---
|
||||||
|
- vars:
|
||||||
|
mysql_parameters: &mysql_params
|
||||||
|
login_user: '{{ mysql_user }}'
|
||||||
|
login_password: '{{ mysql_password }}'
|
||||||
|
login_host: 127.0.0.1
|
||||||
|
login_port: '{{ mysql_primary_port }}'
|
||||||
|
block:
|
||||||
|
- name: Drop mysql user if exists
|
||||||
|
mysql_user:
|
||||||
|
<<: *mysql_params
|
||||||
|
name: '{{ user_name_1 }}'
|
||||||
|
state: absent
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: create user with two grants
|
||||||
|
mysql_user:
|
||||||
|
<<: *mysql_params
|
||||||
|
name: "{{ user_name_1 }}"
|
||||||
|
password: "{{ user_password_1 }}"
|
||||||
|
update_password: on_create
|
||||||
|
priv: '*.*:SELECT,GRANT'
|
||||||
|
|
||||||
|
- name: user must have only on priv, grant priv must be dropped
|
||||||
|
register: result
|
||||||
|
mysql_user:
|
||||||
|
<<: *mysql_params
|
||||||
|
name: "{{ user_name_1 }}"
|
||||||
|
password: "{{ user_password_1 }}"
|
||||||
|
update_password: on_create
|
||||||
|
priv: '*.*:SELECT'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result is not failed
|
||||||
|
- result is changed
|
||||||
|
|
||||||
|
- name: immutable - user must have only on priv, grant priv must be dropped
|
||||||
|
register: result
|
||||||
|
mysql_user:
|
||||||
|
<<: *mysql_params
|
||||||
|
name: "{{ user_name_1 }}"
|
||||||
|
password: "{{ user_password_1 }}"
|
||||||
|
update_password: on_create
|
||||||
|
priv: '*.*:SELECT'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result is not failed
|
||||||
|
- result is not changed
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: drop user
|
||||||
|
mysql_user:
|
||||||
|
<<: *mysql_params
|
||||||
|
name: '{{ user_name_1 }}'
|
||||||
|
state: absent
|
||||||
|
ignore_errors: true
|
|
@ -1,8 +0,0 @@
|
||||||
plugins/modules/mysql_db.py validate-modules:doc-elements-mismatch
|
|
||||||
plugins/modules/mysql_db.py validate-modules:parameter-list-no-elements
|
|
||||||
plugins/modules/mysql_db.py validate-modules:use-run-command-not-popen
|
|
||||||
plugins/modules/mysql_info.py validate-modules:doc-elements-mismatch
|
|
||||||
plugins/modules/mysql_info.py validate-modules:parameter-list-no-elements
|
|
||||||
plugins/modules/mysql_query.py validate-modules:parameter-list-no-elements
|
|
||||||
plugins/modules/mysql_user.py validate-modules:undocumented-parameter
|
|
||||||
plugins/modules/mysql_variables.py validate-modules:doc-required-mismatch
|
|
|
@ -1,8 +0,0 @@
|
||||||
plugins/modules/mysql_db.py validate-modules:doc-elements-mismatch
|
|
||||||
plugins/modules/mysql_db.py validate-modules:parameter-list-no-elements
|
|
||||||
plugins/modules/mysql_db.py validate-modules:use-run-command-not-popen
|
|
||||||
plugins/modules/mysql_info.py validate-modules:doc-elements-mismatch
|
|
||||||
plugins/modules/mysql_info.py validate-modules:parameter-list-no-elements
|
|
||||||
plugins/modules/mysql_query.py validate-modules:parameter-list-no-elements
|
|
||||||
plugins/modules/mysql_user.py validate-modules:undocumented-parameter
|
|
||||||
plugins/modules/mysql_variables.py validate-modules:doc-required-mismatch
|
|
|
@ -6,3 +6,5 @@ plugins/modules/mysql_info.py validate-modules:parameter-list-no-elements
|
||||||
plugins/modules/mysql_query.py validate-modules:parameter-list-no-elements
|
plugins/modules/mysql_query.py validate-modules:parameter-list-no-elements
|
||||||
plugins/modules/mysql_user.py validate-modules:undocumented-parameter
|
plugins/modules/mysql_user.py validate-modules:undocumented-parameter
|
||||||
plugins/modules/mysql_variables.py validate-modules:doc-required-mismatch
|
plugins/modules/mysql_variables.py validate-modules:doc-required-mismatch
|
||||||
|
plugins/module_utils/mysql.py pylint:unused-import
|
||||||
|
plugins/module_utils/version.py pylint:unused-import
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
plugins/modules/mysql_db.py validate-modules:use-run-command-not-popen
|
|
||||||
plugins/modules/mysql_user.py validate-modules:parameter-type-not-in-doc
|
|
||||||
plugins/modules/mysql_user.py validate-modules:undocumented-parameter
|
|
|
@ -4,10 +4,6 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
try:
|
|
||||||
from unittest.mock import MagicMock
|
|
||||||
except ImportError:
|
|
||||||
from mock import MagicMock
|
|
||||||
|
|
||||||
from ansible_collections.community.mysql.plugins.module_utils.user import (
|
from ansible_collections.community.mysql.plugins.module_utils.user import (
|
||||||
handle_grant_on_col,
|
handle_grant_on_col,
|
||||||
|
@ -15,7 +11,6 @@ from ansible_collections.community.mysql.plugins.module_utils.user import (
|
||||||
normalize_col_grants,
|
normalize_col_grants,
|
||||||
sort_column_order
|
sort_column_order
|
||||||
)
|
)
|
||||||
from ..utils import dummy_cursor_class
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue