Skip to content

Commit

Permalink
Merge pull request #1122 from t-woerner/fix_ipa_command_invalid_param…
Browse files Browse the repository at this point in the history
…_choices_for_IPA_4_6

ansible_freeipa_module: Fix ipa_command_invalid_param_choices
  • Loading branch information
rjeffman authored Jul 21, 2023
2 parents 88d4a36 + d58b492 commit 1a48a0f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plugins/module_utils/ansible_freeipa_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,8 +1192,21 @@ def ipa_command_invalid_param_choices(self, command, name, value):
if not hasattr(api.Command[command].params[name], "cli_metavar"):
self.fail_json(msg="The parameter '%s' of the command '%s' does "
"not have choices." % (name, command))
_choices = ast.literal_eval(
api.Command[command].params[name].cli_metavar)
# For IPA 4.6 (RHEL-7):
# - krbprincipalauthind in host_add does not have choices defined
# - krbprincipalauthind in service_add does not have choices defined
#
# api.Command[command].params[name].cli_metavar returns "STR" and
# ast.literal_eval failes with a ValueError "malformed string".
#
# There is no way to verify that the given values are valid or not in
# this case. The check is done later on while applying the change
# with host_add, host_mod, service_add and service_mod.
try:
_choices = ast.literal_eval(
api.Command[command].params[name].cli_metavar)
except ValueError:
return None
return (set(value or []) - set([""])) - set(_choices)

@staticmethod
Expand Down

0 comments on commit 1a48a0f

Please sign in to comment.