use python fallback to avoid error on old mongo version without roles

This commit is contained in:
Guillaume Dufour 2016-02-28 08:05:20 +01:00 committed by Matt Clay
parent 467d9a8090
commit dc83f2c6d7

View file

@ -278,7 +278,7 @@ def main():
uinfo = user_find(client, user, db_name)
if update_password != 'always' and uinfo:
password = None
if 'roles' in uinfo and list(map((lambda x: x['role']), uinfo['roles'])) == roles:
if list(map((lambda x: x['role']), uinfo.get('roles', []))) == roles:
module.exit_json(changed=False, user=user)
if module.check_mode: