Unable to login with credentials used to create mongo user

Hi,

I’ve open an issue on Github (https://github.com/ansible/ansible/issues/7157) about mongo_user module.

I’m trying to use mongo_user to create some users. However, I’m unable to login with the credentials specified.

I use the following commands :

  • name: add Mongo admin
    mongodb_user: database=admin name=bigadmin password=BigBosS roles=‘root’ state=present
    sudo: true

and then, if I try to connect, it fails :
mongo admin -u bigadmin -p BigBosS
=> auth failed

But if I add this user manually on mongo it works
db.addUser({user: “superadmin”, pwd: “BigBosS”, roles: [{role:“root”, db:“admin”}]})

mongo admin -u superadmin-p BigBosS
=> auth successfull

The weird thing is that the password is different in the admin db.system.users collection :

db.system.users.find()
{ “_id” : “admin.bigadmin”, “user” : “bigadmin”, “db” : “admin”, “credentials” : { “MONGODB-CR” : “8757ec7d8b6d462f69e10c51d36ff9c1” }, “roles” : [ { “role” : “root”, “db” : “admin” } ] }
{ “_id” : “admin.superadmin”, “user” : “superadmin”, “db” : “admin”, “credentials” : { “MONGODB-CR” : “96dfab41377d3965ce104f7b1f3d8044” }, “roles” : [ { “role” : “root”, “db” : “admin” } ] }
I think the password shoud be identical.

Any idea about that ?