Skip to content

Commit

Permalink
Add current_passwd parameter to zabbix_user for self password override (
Browse files Browse the repository at this point in the history
  • Loading branch information
loricvdt authored Jul 11, 2023
1 parent b89f54b commit 4b48b1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/current_passwd_user_module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- zabbix_user module - add current_passwd optional parameter to enable password updating of the currently logged in user (https://www.zabbix.com/documentation/6.4/en/manual/api/reference/user/update)
13 changes: 13 additions & 0 deletions plugins/modules/zabbix_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
- Password will not be updated on subsequent runs without setting this value to yes.
default: no
type: bool
current_passwd:
description:
- Current password for the user when overriding its password.
- Required when overriding the logged in user's password.
- https://www.zabbix.com/documentation/6.4/en/manual/api/reference/user/update
required: false
type: str
lang:
description:
- Language code of the user's language.
Expand Down Expand Up @@ -605,6 +612,7 @@ def update_user(
timezone,
role_name,
override_passwd,
current_passwd,
):

user_ids = {}
Expand All @@ -626,6 +634,8 @@ def update_user(

if override_passwd:
request_data["passwd"] = passwd
if current_passwd:
request_data["current_passwd"] = current_passwd

request_data["roleid"] = (
self.get_roleid_by_name(role_name) if role_name else None
Expand Down Expand Up @@ -685,6 +695,7 @@ def main():
override_passwd=dict(
type="bool", required=False, default=False, no_log=False
),
current_passwd=dict(type="str", required=False, no_log=True),
lang=dict(
type="str",
choices=[
Expand Down Expand Up @@ -760,6 +771,7 @@ def main():
usrgrps = module.params["usrgrps"]
passwd = module.params["passwd"]
override_passwd = module.params["override_passwd"]
current_passwd = module.params["current_passwd"]
lang = module.params["lang"]
theme = module.params["theme"]
autologin = module.params["autologin"]
Expand Down Expand Up @@ -833,6 +845,7 @@ def main():
timezone,
role_name,
override_passwd,
current_passwd,
)
else:
diff_check_result = True
Expand Down

0 comments on commit 4b48b1a

Please sign in to comment.