Test we can log in with the created user to the DB:
# mongo -u unixtest -p password unixtest_db
MongoDB shell version v5.0.9
connecting to: mongodb://127.0.0.1:27017/unixtest_db?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("37b03869-f8dd-4ab7-a004-55b4882f5aa2") }
MongoDB server version: 5.0.9
Note: Cannot determine if automation is active
unixtesttst:PRIMARY>
Change password in hiera:
mongodb::mongodb_db:
'unixtest_db': # DB name
user : unixtest
password : >
ENC[PKCS7,MIIBeQYJKoZIhvcNA... J] # password is password2
roles :
- dbOwner
Apply the config on the mongo server side. In the puppet client output we have:
Notice: /Stage[main]/mongodb/Mongodb::Db[unixtest_db]/Mongodb_user[User unixtest on db unixtest_db]/password_hash: defined 'password_hash' as '259ee30be19a726b1e0ce6788ee85822'
Try to log in with a new password (failed):
Try to log in with the old password (successfull):
What are you seeing
After Step 1 authentication succeeds. But after changing to another password it fails:
# mongo -u unixtest -p password2 unixtest_db
MongoDB shell version v5.0.9
connecting to: mongodb://127.0.0.1:27017/unixtest_db?compressors=disabled&gssapiServiceName=mongodb
Error: Authentication failed. :
connect@src/mongo/shell/mongo.js:372:17
@(connect):2:6
exception: connect failed
exiting with code 1
Trying to authenticate using the previous password works:
# mongo -u unixtest -p password unixtest_db
MongoDB shell version v5.0.9
connecting to: mongodb://127.0.0.1:27017/unixtest_db?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("def6181d-5cfe-4801-a3bd-51dd9c8a07f0") }
MongoDB server version: 5.0.9
Note: Cannot determine if automation is active
unixtesttst:PRIMARY>
What behaviour did you expect instead
Be able to log in with a new password
Output log
Any additional information you'd like to impart
MongoDB database server: 5.0.9
In the debug messages I see:
Debug: Executing: '/usr/bin/mongo unixtest_db --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); db.runCommand({"updateUser":"unixtest","pwd":"2a7a72f6fc32c68fb479e9530e3c50c6","digestPassword":false})'
Notice: /Stage[main]/mongodb/Mongodb::Db[unixtest_db]/Mongodb_user[User unixtest on db unixtest_db]/password_hash: defined 'password_hash' as '2a7a72f6fc32c68fb479e9530e3c50c6' (corrective)
UPDATE
If I make a terminal command from the puppet-agent debug message and run it I get:
Affected Puppet, Ruby, OS and module versions/distributions
How to reproduce (e.g Puppet code you use)
In the manifest we have standard:
Change password in hiera:
Apply the config on the mongo server side. In the puppet client output we have:
Notice: /Stage[main]/mongodb/Mongodb::Db[unixtest_db]/Mongodb_user[User unixtest on db unixtest_db]/password_hash: defined 'password_hash' as '259ee30be19a726b1e0ce6788ee85822'
Try to log in with a new password (failed):
Try to log in with the old password (successfull):
What are you seeing
After Step 1 authentication succeeds. But after changing to another password it fails:
Trying to authenticate using the previous password works:
What behaviour did you expect instead
Be able to log in with a new password
Output log
Any additional information you'd like to impart
MongoDB database server: 5.0.9
In the debug messages I see:
UPDATE
If I make a terminal command from the puppet-agent debug message and run it I get:
So it tries to use SHA-256 instead of expected SHA-1.
The problem is solved if we add the mechanism parameter to the command:
After that we can log in with a new password. Working on the fix.