Repository navigation
fix(roles/mongodb): keep the dump password off the command line - #518
Merged
Merged
Conversation
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mongodb-dumppassed the password of the dump user to mongosh and mongodump on the command line, where every local user can read it in the process list. Follows #505 (same for MariaDB) and #509 (dropped MongoDB < 7.0, so no fallback for the legacymongoshell or a mongodump without--configis needed).fix(roles/mongodb): keep the dump password off the command line
/etc/mongodb-dump.confto/etc/mongodb-dump-login.json({"password": ...}, 0600). mongodump reads it with--config, which rejects any other key, so the user name stays inmongodb-dump.conf. mongosh reads it in JavaScript (require("fs")) and logs in withdb.auth(); the user name comes through the environment instead of being quoted into the JavaScript.mongofallback is gone.mongodb__dump_only_if_hiddenskipped hidden members instead of non-hidden ones, and grepped for the legacy shell's output format, so it never matched with mongosh and every member was dumped. A failing mongodump printed an error but the script still exited 0.mongodb(no scenario existed): authorization on, a dump password with\ " # ' : @ /and%, verifies that the dump contains a test database.fix(roles/mongodb): stop reporting unchanged MongoDB users as changed
The new scenario failed idempotence:
mongodb_userwithupdate_password: alwaysreports a change on every run,on_createnever applies a changed password. A read-only pymongo login with the inventory password (JSON on stdin,no_log) decides:alwaysonly if the login fails (AuthenticationFailed, also for a user that does not exist yet), elseon_create. Applied to the dump user and tomongodb__users__*_var.Verified:
mongodbon Debian 12, Rocky 8, 9, 10, Ubuntu 22.04 and 24.04: converge, verify, idempotence, verify.Not changed, but found: with authorization, the file-based method cannot lock the instance, since the dump user only has the
backuprole, which lacksfsync(not authorized on admin to execute command { fsync: 1, lock: true }). The script then copies/var/lib/mongowithout the lock and fails at the unlock (exit 3).