@ -192,11 +192,7 @@ def user_add(module, client, db_name, user, password, roles):
if roles is None :
if roles is None :
db . add_user ( user , password , False )
db . add_user ( user , password , False )
else :
else :
try :
db . add_user ( user , password , None , roles = roles )
db . add_user ( user , password , None , roles = roles )
except OperationFailure , e :
err_msg = str ( e )
module . fail_json ( msg = err_msg )
def user_remove ( module , client , db_name , user ) :
def user_remove ( module , client , db_name , user ) :
exists = user_find ( client , user , db_name )
exists = user_find ( client , user , db_name )
@ -339,16 +335,16 @@ def main():
if password is None and update_password == ' always ' :
if password is None and update_password == ' always ' :
module . fail_json ( msg = ' password parameter required when adding a user unless update_password is set to on_create ' )
module . fail_json ( msg = ' password parameter required when adding a user unless update_password is set to on_create ' )
uinfo = user_find ( client , user , db_name )
try :
if update_password != ' always ' and uinfo :
uinfo = user_find ( client , user , db_name )
password = None
if update_password != ' always ' and uinfo :
if not check_if_roles_changed ( uinfo , roles , db_name ) :
password = None
module . exit_json ( changed = False , user = user )
if not check_if_roles_changed ( uinfo , roles , db_name ) :
module . exit_json ( changed = False , user = user )
if module . check_mode :
if module . check_mode :
module . exit_json ( changed = True , user = user )
module . exit_json ( changed = True , user = user )
try :
user_add ( module , client , db_name , user , password , roles )
user_add ( module , client , db_name , user , password , roles )
except OperationFailure , e :
except OperationFailure , e :
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 ) )