mongodb_info -- Gather information about MongoDB instance.

Synopsis

Gather information about MongoDB instance.

Requirements

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

Parameters

filter (False, list, None)

Limit the collected information by comma separated string or YAML list.

Allowable values are general, databases, total_size, parameters, users, roles.

By default, collects all subsets.

You can use '!' before value (for example, !users) to exclude it from the information.

If you pass including and excluding values to the filter, for example, filter=!general,users, the excluding values, !general in this case, will be ignored.

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

  • Requires the pymongo Python package on the remote host, version 2.4.2+.

Examples

- name: Gather all supported information
  community.mongodb.mongodb_info:
    login_user: admin
    login_password: secret
  register: result

- name: Show gathered info
  debug:
    msg: '{{ result }}'

- name: Gather only information about databases and their total size
  community.mongodb.mongodb_info:
    login_user: admin
    login_password: secret
    filter: databases, total_size

- name: Gather all information except parameters
  community.mongodb.mongodb_info:
    login_user: admin
    login_password: secret
    filter: '!parameters'

Return Values

general (always, dict, {'allocator': 'tcmalloc', 'bits': 64, 'storageEngines': ['biggie'], 'version': '4.2.3', 'maxBsonObjectSize': 16777216})
General instance information.
databases (always, dict, {'admin': {'empty': False, 'sizeOnDisk': 245760}, 'config': {'empty': False, 'sizeOnDisk': 110592}})
Database information.
total_size (always, int, 397312)
Total size of all databases in bytes.
users (always, dict, {'db': {'new_user': {'_id': 'config.new_user', 'mechanisms': ['SCRAM-SHA-1', 'SCRAM-SHA-256'], 'roles': []}}})
User information.
roles (always, dict, {'db': {'restore': {'inheritedRoles': [], 'isBuiltin': True, 'roles': []}}})
Role information.
parameters (always, dict, {'maxOplogTruncationPointsAfterStartup': 100, 'maxOplogTruncationPointsDuringStartup': 100, 'maxSessions': 1000000})
Server parameters information.

Status

Authors

  • Andrew Klychkov (@Andersson007)