summaryrefslogtreecommitdiffstats
path: root/lib/openldap
diff options
context:
space:
mode:
Diffstat (limited to 'lib/openldap')
-rw-r--r--lib/openldap9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/openldap b/lib/openldap
index 983299a..020017c 100644
--- a/lib/openldap
+++ b/lib/openldap
@@ -319,30 +319,37 @@ def main():
elif state == "present":
if target is not None:
# bind only once per LDIF file to
l = ldap.initialize( 'ldapi://' )
l.sasl_interactive_bind_s('', ldap.sasl.external())
parser = LDIFCallback( module, open(target, 'r')
, partial(processEntry,module,l) )
parser.parse()
l.unbind_s()
changed = parser.changed
elif mod is not None:
changed = loadModule(module, mod)
else:
module.fail_json(msg="missing target or module")
except subprocess.CalledProcessError, e:
module.fail_json(rv=e.returncode, msg=e.output.rstrip())
except ldap.LDAPError, e:
- module.fail_json(msg=e.args[0]['info'])
+ e = e.args[0]
+ if 'info' in e.keys():
+ msg = e['info']
+ elif 'desc' in e.keys():
+ msg = e['desc']
+ else:
+ msg = str(e)
+ module.fail_json(msg=msg)
except KeyError, e:
module.fail_json(msg=str(e))
module.exit_json(changed=changed)
# this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main()