From a69446021b6e31207dbe22e615df0c4e4bb05130 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman <rjeffman@redhat.com> Date: Tue, 11 Apr 2023 18:45:49 -0300 Subject: [PATCH] ipapwpolicy: simplified and faster attribute verification Use a simpler and faster 'any()' test instead of creating two lists and checking if resulting list is empty. --- plugins/modules/ipapwpolicy.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/modules/ipapwpolicy.py b/plugins/modules/ipapwpolicy.py index ea794fc9..ca9052c8 100644 --- a/plugins/modules/ipapwpolicy.py +++ b/plugins/modules/ipapwpolicy.py @@ -230,17 +230,15 @@ def check_supported_params( "pwpolicy_add", "passwordgracelimit") # If needed, report unsupported password checking paramteres - if not has_password_check: - check_password_params = [maxrepeat, maxsequence, dictcheck, usercheck] - unsupported = [ - x for x in check_password_params if x is not None - ] - if unsupported: - module.fail_json( - msg="Your IPA version does not support arguments: " - "maxrepeat, maxsequence, dictcheck, usercheck.") - - if gracelimit is not None and not has_gracelimit: + if ( + not has_password_check + and any([maxrepeat, maxsequence, dictcheck, usercheck]) + ): + module.fail_json( + msg="Your IPA version does not support arguments: " + "maxrepeat, maxsequence, dictcheck, usercheck.") + + if not has_gracelimit and gracelimit is not None: module.fail_json( msg="Your IPA version does not support 'gracelimit'.") -- GitLab