mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
[PR #10955/e84f59a6 backport][stable-10] fix(pritunl_user): improve resilience to null or missing user parameters (#11013)
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
* simplify user params comparison
* simplify list fetch
* simplify remote value retrieval
---------
(cherry picked from commit e84f59a62d)
Co-authored-by: David Jenkins <david.jenkins@twosixtech.com>
Co-authored-by: djenkins <djenkins@twosix.net>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
103bde7764
commit
0ed510a050
2 changed files with 7 additions and 3 deletions
|
|
@ -210,16 +210,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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue