mongodb_rs_status
3.91 KB
-
Upgrades to mongo_replica_set to handle initialization · cda15d39
Do a bit more error checking before asking for the replica set. The new mongo play wants to be able to run this against an unconfigured Mongo to find out "Do you even have a replica set?" which this can now answer (the try/except portion). In the case where mongo was started without a replSet configured (or running getCmdLineOpts fails for an OperationFailure reason), we return a dictionary where status is not included to allow tasks to detect the failure. Unfortunately, Ansible doesn't provide an easy way to log back why you didn't get a replica set doc. Documentation improvements for this module Discusses the return values and some examples of checking them. Simplify get_replset If the find_one for a replset fails, just return None. We don't need to worry about getting back a dictionary which contains a 'config' key (presumably this is from an earlier iteration of the code which called getReplSetStatus which does act like that). Rather than raising the exception, use the friendly error here. I assume the raise/module.fail_json double header was leftover cruft from earlier development. Make the module work without rs being configured Initially, this module always tried to find and connect to a primary, however, during replica set initialization, there is no primary so we need to fall back to just connecting to the machine specified. This is detected by catching the replSetGetStatus failure and falling back to the bare get_client method which refactors the connection.
Kevin Falcone committed