From 3984380acb4f3a2aeab9f54d10b281a1d057bbd2 Mon Sep 17 00:00:00 2001 From: "E.S. Rosenberg a.k.a. Keeper of the Keys" Date: Thu, 6 Mar 2025 12:07:00 +0200 Subject: [PATCH] Add check_mode support. Signed-off-by: E.S. Rosenberg a.k.a. Keeper of the Keys --- plugins/module_utils/user.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index 0d112d9..c35b945 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -553,12 +553,13 @@ def user_mod(cursor, user, host, host_all, password, encrypted, final_attributes = attributes_get(cursor, user, host) if user_is_locked(cursor, user, host) != locked: - if locked: - cursor.execute("ALTER USER %s@%s ACCOUNT LOCK", (user, host)) - msg = 'User locked' - else: - cursor.execute("ALTER USER %s@%s ACCOUNT UNLOCK", (user, host)) - msg = 'User unlocked' + if not module.check_mode: + if locked: + cursor.execute("ALTER USER %s@%s ACCOUNT LOCK", (user, host)) + msg = 'User locked' + else: + cursor.execute("ALTER USER %s@%s ACCOUNT UNLOCK", (user, host)) + msg = 'User unlocked' changed = True if role: