mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
fix(pritunl_user): improve resilience to null or missing user parameters (#10955)
* fix(pritunl_user): improve resilience to null or missing user parameters * added changelog fragment - 10955 * standardize 10955 changelog fragment content Co-authored-by: Felix Fontein <felix@fontein.de> * simplify user params comparison Co-authored-by: Felix Fontein <felix@fontein.de> * simplify list fetch Co-authored-by: Felix Fontein <felix@fontein.de> * simplify remote value retrieval Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: djenkins <djenkins@twosix.net> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -208,16 +208,18 @@ def add_or_update_pritunl_user(module):
|
||||
for key in user_params.keys():
|
||||
# When a param is not specified grab existing ones to prevent from changing it with the PUT request
|
||||
if user_params[key] is None:
|
||||
user_params[key] = users[0][key]
|
||||
user_params[key] = users[0].get(key)
|
||||
|
||||
# 'groups' and 'mac_addresses' are list comparison
|
||||
if key == "groups" or key == "mac_addresses":
|
||||
if set(users[0][key]) != set(user_params[key]):
|
||||
remote_list = users[0].get(key) or []
|
||||
local_list = user_params[key] or []
|
||||
if set(remote_list) != set(local_list):
|
||||
user_params_changed = True
|
||||
|
||||
# otherwise it is either a boolean or a string
|
||||
else:
|
||||
if users[0][key] != user_params[key]:
|
||||
if users[0].get(key) != user_params[key]:
|
||||
user_params_changed = True
|
||||
|
||||
# Trigger a PUT on the API to update the current user if settings have changed
|
||||
|
||||
Reference in New Issue
Block a user