mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-31 11:54:47 +00:00
ipaservice: Remove custom error handler.
Use IPAAnsibleModule default error handler for member arguments instead of a custom one.
This commit is contained in:
@@ -412,23 +412,6 @@ def init_ansible_module():
|
|||||||
return ansible_module
|
return ansible_module
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
|
||||||
def result_handler(module, result, command, name, args, errors):
|
|
||||||
# Get all errors
|
|
||||||
# All "already a member" and "not a member" failures in the
|
|
||||||
# result are ignored. All others are reported.
|
|
||||||
if "failed" in result and len(result["failed"]) > 0:
|
|
||||||
for item in result["failed"]:
|
|
||||||
failed_item = result["failed"][item]
|
|
||||||
for member_type in failed_item:
|
|
||||||
for member, failure in failed_item[member_type]:
|
|
||||||
if "already a member" in failure \
|
|
||||||
or "not a member" in failure:
|
|
||||||
continue
|
|
||||||
errors.append("%s: %s %s: %s" % (
|
|
||||||
command, member_type, member, failure))
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
ansible_module = init_ansible_module()
|
ansible_module = init_ansible_module()
|
||||||
|
|
||||||
@@ -918,13 +901,9 @@ def main():
|
|||||||
else:
|
else:
|
||||||
ansible_module.fail_json(msg="Unkown state '%s'" % state)
|
ansible_module.fail_json(msg="Unkown state '%s'" % state)
|
||||||
|
|
||||||
# Check mode exit
|
|
||||||
if ansible_module.check_mode:
|
|
||||||
ansible_module.exit_json(changed=len(commands) > 0, **exit_args)
|
|
||||||
|
|
||||||
# Execute commands
|
# Execute commands
|
||||||
|
changed = ansible_module.execute_ipa_commands(
|
||||||
changed = ansible_module.execute_ipa_commands(commands, result_handler)
|
commands, fail_on_member_errors=True)
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
ansible_module.exit_json(changed=changed, **exit_args)
|
ansible_module.exit_json(changed=changed, **exit_args)
|
||||||
|
|||||||
Reference in New Issue
Block a user