mongodb_balancer -- Manages the MongoDB Sharded Cluster Balancer.

Synopsis

Manages the MongoDB Sharded Cluster Balancer.

Start or stop the balancer.

Adjust the cluster chunksize.

Enable or disable autosplit.

Add or remove a balancer window.

Requirements

The below requirements are needed on the host that executes this module.

Parameters

autosplit (False, bool, None)
Disable or enable the autosplit flag in the config.settings collection.
chunksize (False, int, None)

Control the size of chunks in the sharded cluster.

Value should be given in MB.

state (False, str, started)
Manage the Balancer for the Cluster
mongos_process (False, str, mongos)

Provide a custom name for the mongos process.

Most users can ignore this setting.

window (False, raw, None)

Schedule the balancer window.

Provide the following dictionary keys start, stop, state

The state key should be "present" or "absent".

The start and stop keys are ignored when state is "absent".

start and stop should be strings in "HH:MM" format indicating the time bounds of the window.

login_user (False, str, None)

The MongoDB user to login with.

Required when login_password is specified.

login_password (False, str, None)

The password used to authenticate with.

Required when login_user is specified.

login_database (False, str, admin)
The database where login credentials are stored.
login_host (False, str, localhost)
The host running MongoDB instance to login to.
login_port (False, int, 27017)
The MongoDB server port to login to.
strict_compatibility (optional, bool, True)
Enforce strict requirements for pymongo and MongoDB software versions
ssl (False, bool, False)
Whether to use an SSL connection when connecting to the database.
ssl_cert_reqs (False, str, CERT_REQUIRED)
Specifies whether a certificate is required from the other side of the connection, and whether it will be validated if provided.
ssl_ca_certs (False, str, None)
The ssl_ca_certs option takes a path to a CA file.
ssl_crlfile (False, str, None)
The ssl_crlfile option takes a path to a CRL file.
ssl_certfile (False, str, None)
Present a client certificate using the ssl_certfile option.
ssl_keyfile (False, str, None)
Private key for the client certificate.
ssl_pem_passphrase (False, str, None)
Passphrase to decrypt encrypted private keys.
auth_mechanism (False, str, None)
Authentication type.
connection_options (False, list, None)

Additional connection options.

Supply as a list of dicts or strings containing key value pairs seperated with '='.

Notes

Note

Examples

- name: Start the balancer
  community.mongodb.mongodb_balancer:
    state: started

- name: Stop the balancer and disable autosplit
  community.mongodb.mongodb_balancer:
    state: stopped
    autosplit: false

- name: Enable autosplit
  community.mongodb.mongodb_balancer:
    autosplit: true

- name: Change the default chunksize to 128MB
  community.mongodb.mongodb_balancer:
    chunksize: 128

- name: Add or update a balancing window
  community.mongodb.mongodb_balancer:
    window:
      start: "23:00"
      stop: "06:00"
      state: "present"

- name: Remove a balancing window
  community.mongodb.mongodb_balancer:
    window:
      state: "absent"

Return Values

changed (success, bool, )
Whether the balancer state or autosplit changed.
old_balancer_state (When balancer state is changed, str, )
The previous state of the balancer
new_balancer_state (When balancer state is changed, str, )
The new state of the balancer.
old_autosplit (When autosplit is changed., str, )
The previous state of autosplit.
new_autosplit (When autosplit is changed., str, )
The new state of autosplit.
old_chunksize (When chunksize is changed., int, )
The previous value for chunksize.
new_chunksize (When chunksize is changed., int, )
The new value for chunksize.
msg (failure, str, )
A short description of what happened.
failed (failed, bool, )
If something went wrong

Status

Authors

  • Rhys Campbell (@rhysmeister)