- Changes requested/suggested by @Andersson007

- Example usage
- Changelog fragment

Signed-off-by: E.S. Rosenberg a.k.a. Keeper of the Keys <es.rosenberg+github@gmail.com>
This commit is contained in:
E.S. Rosenberg a.k.a. Keeper of the Keys 2025-03-05 15:51:20 +02:00
parent 17e398f5a2
commit d839871d1e
3 changed files with 15 additions and 14 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- mysql_user - add ``locked`` option to lock/unlock users, this is mainly used to have users that will act as definers on stored procedures.

View file

@ -193,7 +193,7 @@ options:
locked:
description:
- Lock account to prevent connections using it, this is primarily used for creating a user that will act as a DEFINER on stored procedures.
- The C(default) is C(false)
default: false
type: bool
version_added: '3.13.0'
@ -408,6 +408,13 @@ EXAMPLES = r'''
priv:
'db1.*': DELETE
- name: Create locked user to act as a definer on procedures
community.mysql.mysql_user:
name: readonly_procedures_locked
locked: true
priv:
db1.*: SELECT
# Example .my.cnf file for setting the root password
# [client]
# user=root
@ -478,7 +485,7 @@ def main():
column_case_sensitive=dict(type='bool', default=None), # TODO 4.0.0 add default=True
password_expire=dict(type='str', choices=['now', 'never', 'default', 'interval'], no_log=True),
password_expire_interval=dict(type='int', required_if=[('password_expire', 'interval', True)], no_log=True),
locked=dict(type='bool', default='no'),
locked=dict(type='bool', default='false'),
)
module = AnsibleModule(
argument_spec=argument_spec,

View file

@ -22,9 +22,8 @@
community.mysql.mysql_user:
<<: *mysql_params
name: mysql_locked_user
host: '%'
password: 'msandbox'
locked: yes
locked: true
priv:
'mysql_lock_user_test.*': 'SELECT'
@ -41,8 +40,7 @@
community.mysql.mysql_user:
<<: *mysql_params
name: mysql_locked_user
host: '%'
locked: no
locked: false
priv:
'mysql_lock_user_test.*': 'SELECT'
@ -59,16 +57,14 @@
community.mysql.mysql_user:
<<: *mysql_params
name: mysql_locked_user
host: '%'
state: absent
- name: Mysql_user Lock user | create unlocked | Create test user
community.mysql.mysql_user:
<<: *mysql_params
name: mysql_locked_user
host: '%'
password: 'msandbox'
locked: no
locked: false
priv:
'mysql_lock_user_test.*': 'SELECT'
@ -85,8 +81,7 @@
community.mysql.mysql_user:
<<: *mysql_params
name: mysql_locked_user
host: '%'
locked: yes
locked: true
priv:
'mysql_lock_user_test.*': 'SELECT'
@ -103,14 +98,12 @@
community.mysql.mysql_user:
<<: *mysql_params
name: mysql_locked_user
host: '%'
state: absent
- name: Mysql_user Lock user | create default | Create test user
community.mysql.mysql_user:
<<: *mysql_params
name: mysql_locked_user
host: '%'
password: 'msandbox'
priv:
'mysql_lock_user_test.*': 'SELECT'
@ -128,7 +121,6 @@
community.mysql.mysql_user:
<<: *mysql_params
name: mysql_locked_user
host: '%'
state: absent
# ========================= Teardown ======================================