mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2026-02-04 07:11:49 +00:00
Fix user module for default roles (#718)
* mysql_user: fix crash when default role is set * tests: add DEFAULT role to user to force the module to fail * Add changelog fragment --------- Co-authored-by: “tkr” <“tim.kruth@wiit.cloud”>
This commit is contained in:
parent
67f1460070
commit
6f0c0be929
4 changed files with 59 additions and 2 deletions
|
|
@ -0,0 +1,43 @@
|
|||
---
|
||||
- vars:
|
||||
mysql_parameters: &mysql_params
|
||||
login_user: '{{ mysql_user }}'
|
||||
login_password: '{{ mysql_password }}'
|
||||
login_host: '{{ mysql_host }}'
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
|
||||
block:
|
||||
- name: Issue-710 | Create user with DEFAULT privileges
|
||||
community.mysql.mysql_user:
|
||||
<<: *mysql_params
|
||||
name: "{{ user_name_1 }}"
|
||||
password: "{{ user_password_1 }}"
|
||||
state: present
|
||||
|
||||
- name: Issue-710 | Create role to use as default
|
||||
community.mysql.mysql_role:
|
||||
<<: *mysql_params
|
||||
name: developers
|
||||
state: present
|
||||
priv: '*.*:ALL'
|
||||
members:
|
||||
- "{{ user_name_1 }}@localhost"
|
||||
|
||||
- name: Issue-710 | Set default role for db_user1
|
||||
community.mysql.mysql_query:
|
||||
<<: *mysql_params
|
||||
query: >-
|
||||
SET DEFAULT ROLE developers {{ (db_engine == 'mysql') | ternary('TO', 'FOR') }} {{ user_name_1 }}@localhost
|
||||
|
||||
- name: Issue-710 | Ensure db_user1 can still be altered
|
||||
community.mysql.mysql_user:
|
||||
<<: *mysql_params
|
||||
name: "{{ user_name_1 }}"
|
||||
password: "{{ user_password_1 }}"
|
||||
priv: '*.*:ALL'
|
||||
state: present
|
||||
|
||||
- name: Issue-710 | Ensure mysql_info can still be executed
|
||||
community.mysql.mysql_info:
|
||||
<<: *mysql_params
|
||||
filter: users_info
|
||||
|
|
@ -309,3 +309,7 @@
|
|||
- name: Mysql_user - test user_locking
|
||||
ansible.builtin.import_tasks:
|
||||
file: test_user_locking.yml
|
||||
|
||||
# Test that mysql_user still works with default role set
|
||||
# (https://github.com/ansible-collections/community.mysql/issues/710)
|
||||
- include_tasks: issue-710.yml
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue