mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-04 05:04:23 -07:00
Display a more informative error when InvalidPrivsError is raised (#465) - continued adding fragment for changelog and fixing sanity errors.
This commit is contained in:
parent
d95435e351
commit
d42eadb063
3 changed files with 59 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
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
|
||||||
|
and the exception message granting privileges fails` (https://github.com//pull/435).
|
|
@ -725,7 +725,7 @@ def privileges_grant(cursor, user, host, db_table, priv, tls_requires, maria_rol
|
||||||
try:
|
try:
|
||||||
cursor.execute(query, params)
|
cursor.execute(query, params)
|
||||||
except (mysql_driver.ProgrammingError, mysql_driver.OperationalError, mysql_driver.InternalError) as e:
|
except (mysql_driver.ProgrammingError, mysql_driver.OperationalError, mysql_driver.InternalError) as e:
|
||||||
raise InvalidPrivsError("Error granting privileges, invalid priv string: %s , query: %s , exception: %s." % (priv_string, query, str(e)) )
|
raise InvalidPrivsError("Error granting privileges, invalid priv string: %s , query: %s , exception: %s." % (priv_string, query, str(e)))
|
||||||
|
|
||||||
|
|
||||||
def convert_priv_dict_to_str(priv):
|
def convert_priv_dict_to_str(priv):
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
# test code for privileges for mysql_user module - issue 465
|
||||||
|
# (c) 2014, Wayne Rosario <wrosario@ansible.com>
|
||||||
|
|
||||||
|
# This file is part of Ansible
|
||||||
|
#
|
||||||
|
# Ansible is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Ansible is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
- 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: create admin user with ALL privs, without GRANT OPTIONS
|
||||||
|
mysql_user:
|
||||||
|
<<: *mysql_params
|
||||||
|
name: '{{ user_name_1 }}'
|
||||||
|
password: '{{ user_password_1 }}'
|
||||||
|
priv: '*.{{ db_name }}:ALL'
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- include: assert_user.yml user_name={{user_name_2}} priv='ALL'
|
||||||
|
|
||||||
|
- name: create consumer user with all privileges using admin user
|
||||||
|
mysql_user:
|
||||||
|
<<: *mysql_params
|
||||||
|
name: '{{ user_name_2 }}'
|
||||||
|
password: '{{ user_password_2 }}'
|
||||||
|
login_user: '{{ user_name_1 }}'
|
||||||
|
login_password: '{{ user_password_1 }}'
|
||||||
|
priv: '*.{{ db_name }}:ALL'
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: assert output message for current privileges
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is changed
|
Loading…
Add table
Add a link
Reference in a new issue