Make mongodb modules compile on python 3
This commit is contained in:
parent
1bca0847a4
commit
6963cd8ae7
3 changed files with 14 additions and 8 deletions
|
@ -184,7 +184,8 @@ def main():
|
||||||
try:
|
try:
|
||||||
if param_type == 'int':
|
if param_type == 'int':
|
||||||
value = int(value)
|
value = int(value)
|
||||||
except ValueError, e:
|
except ValueError:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(msg="value '%s' is not %s" % (value, param_type))
|
module.fail_json(msg="value '%s' is not %s" % (value, param_type))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -204,14 +205,16 @@ def main():
|
||||||
if login_user is not None and login_password is not None:
|
if login_user is not None and login_password is not None:
|
||||||
client.admin.authenticate(login_user, login_password, source=login_database)
|
client.admin.authenticate(login_user, login_password, source=login_database)
|
||||||
|
|
||||||
except ConnectionFailure, e:
|
except ConnectionFailure:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(msg='unable to connect to database: %s' % str(e))
|
module.fail_json(msg='unable to connect to database: %s' % str(e))
|
||||||
|
|
||||||
db = client.admin
|
db = client.admin
|
||||||
|
|
||||||
try:
|
try:
|
||||||
after_value = db.command("setParameter", **{param: int(value)})
|
after_value = db.command("setParameter", **{param: int(value)})
|
||||||
except OperationFailure, e:
|
except OperationFailure:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(msg="unable to change parameter: %s" % str(e))
|
module.fail_json(msg="unable to change parameter: %s" % str(e))
|
||||||
|
|
||||||
if "was" not in after_value:
|
if "was" not in after_value:
|
||||||
|
@ -223,6 +226,7 @@ def main():
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -364,7 +364,8 @@ def main():
|
||||||
module.fail_json(msg='The localhost login exception only allows the first admin account to be created')
|
module.fail_json(msg='The localhost login exception only allows the first admin account to be created')
|
||||||
#else: this has to be the first admin user added
|
#else: this has to be the first admin user added
|
||||||
|
|
||||||
except Exception, e:
|
except Exception:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(msg='unable to connect to database: %s' % str(e))
|
module.fail_json(msg='unable to connect to database: %s' % str(e))
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
|
@ -382,7 +383,8 @@ def main():
|
||||||
module.exit_json(changed=True, user=user)
|
module.exit_json(changed=True, user=user)
|
||||||
|
|
||||||
user_add(module, client, db_name, user, password, roles)
|
user_add(module, client, db_name, user, password, roles)
|
||||||
except Exception, e:
|
except Exception:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(msg='Unable to add or update user: %s' % str(e))
|
module.fail_json(msg='Unable to add or update user: %s' % str(e))
|
||||||
|
|
||||||
# Here we can check password change if mongo provide a query for that : https://jira.mongodb.org/browse/SERVER-22848
|
# Here we can check password change if mongo provide a query for that : https://jira.mongodb.org/browse/SERVER-22848
|
||||||
|
@ -393,11 +395,13 @@ def main():
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
try:
|
try:
|
||||||
user_remove(module, client, db_name, user)
|
user_remove(module, client, db_name, user)
|
||||||
except Exception, e:
|
except Exception:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(msg='Unable to remove user: %s' % str(e))
|
module.fail_json(msg='Unable to remove user: %s' % str(e))
|
||||||
|
|
||||||
module.exit_json(changed=True, user=user)
|
module.exit_json(changed=True, user=user)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -39,8 +39,6 @@
|
||||||
/clustering/consul_acl.py
|
/clustering/consul_acl.py
|
||||||
/clustering/consul_kv.py
|
/clustering/consul_kv.py
|
||||||
/clustering/consul_session.py
|
/clustering/consul_session.py
|
||||||
/database/misc/mongodb_parameter.py
|
|
||||||
/database/misc/mongodb_user.py
|
|
||||||
/database/mysql/mysql_replication.py
|
/database/mysql/mysql_replication.py
|
||||||
/database/postgresql/postgresql_ext.py
|
/database/postgresql/postgresql_ext.py
|
||||||
/database/postgresql/postgresql_lang.py
|
/database/postgresql/postgresql_lang.py
|
||||||
|
|
Loading…
Reference in a new issue