mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-05 06:14:42 +00:00
Merge pull request #590 from t-woerner/automember_result_failed_misuse
automember: Fix result["failed"] issues with conditions
This commit is contained in:
@@ -385,7 +385,6 @@ def main():
|
|||||||
if ansible_module.check_mode:
|
if ansible_module.check_mode:
|
||||||
ansible_module.exit_json(changed=len(commands) > 0, **exit_args)
|
ansible_module.exit_json(changed=len(commands) > 0, **exit_args)
|
||||||
|
|
||||||
errors = []
|
|
||||||
for name, command, args in commands:
|
for name, command, args in commands:
|
||||||
try:
|
try:
|
||||||
if name is None:
|
if name is None:
|
||||||
@@ -402,16 +401,13 @@ def main():
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
ansible_module.fail_json(msg="%s: %s: %s" % (command, name,
|
ansible_module.fail_json(msg="%s: %s: %s" % (command, name,
|
||||||
str(ex)))
|
str(ex)))
|
||||||
# Get all errors
|
|
||||||
if "failed" in result and len(result["failed"]) > 0:
|
# result["failed"] is used only for INCLUDE_RE, EXCLUDE_RE
|
||||||
for item in result["failed"]:
|
# if entries could not be added that are already there and
|
||||||
failed_item = result["failed"][item]
|
# it entries could not be removed that are not there.
|
||||||
for member_type in failed_item:
|
# All other issues like invalid attributes etc. are handled
|
||||||
for member, failure in failed_item[member_type]:
|
# as exceptions. Therefore the error section is not here as
|
||||||
errors.append("%s: %s %s: %s" % (
|
# in other modules.
|
||||||
command, member_type, member, failure))
|
|
||||||
if len(errors) > 0:
|
|
||||||
ansible_module.fail_json(msg=", ".join(errors))
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ansible_module.fail_json(msg=str(e))
|
ansible_module.fail_json(msg=str(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user