rolehippie.mongodb
mongodb
Ansible role to install and configure a MongoDB object/document-oriented database.
Sponsor
Building and improving this Ansible role have been sponsored by my current and previous employers like Cloudpunks GmbH and Proact Deutschland GmbH.
Table of content
- Requirements
- Default Variables
- mongodb_admin_update_password
- mongodb_backup_addition_script
- mongodb_backup_cron
- mongodb_backup_enabled
- mongodb_backup_formatting
- mongodb_backup_ignore
- mongodb_backup_path
- mongodb_backup_retention
- mongodb_cloud_monitoring_free_state
- mongodb_exporter_args
- mongodb_exporter_collect_collection
- mongodb_exporter_collect_database
- mongodb_exporter_collect_indexusage
- mongodb_exporter_collect_replicaset
- mongodb_exporter_collect_topmetrics
- mongodb_exporter_connection
- mongodb_exporter_download
- mongodb_exporter_enabled
- mongodb_exporter_password
- mongodb_exporter_username
- mongodb_exporter_version
- mongodb_extra_users
- mongodb_general_users
- mongodb_group
- mongodb_keyfile_content
- mongodb_keyfile_path
- mongodb_keyring
- mongodb_limit_files
- mongodb_limit_procs
- mongodb_logrotate_retention
- mongodb_master_node
- mongodb_metrics_password
- mongodb_metrics_update_password
- mongodb_metrics_username
- mongodb_net_bindip
- mongodb_net_http_enabled
- mongodb_net_ipv6
- mongodb_net_maxconns
- mongodb_net_port
- mongodb_operation_profiling_mode
- mongodb_operation_profiling_slow_op_threshold_ms
- mongodb_oplog_users
- mongodb_pidfile_path
- mongodb_pymongo_version
- mongodb_recursive_enforce_owner
- mongodb_replication_enable_majority_read_concern
- mongodb_replication_oplogsize
- mongodb_replication_params
- mongodb_replication_replindexprefetch
- mongodb_replication_replset
- mongodb_root_admin_password
- mongodb_root_admin_username
- mongodb_root_update_password
- mongodb_security_authorization
- mongodb_security_javascript_enabled
- mongodb_server_version
- mongodb_set_parameters
- mongodb_storage_dirperdb
- mongodb_storage_engine
- mongodb_storage_journal_enabled
- mongodb_storage_path
- mongodb_storage_quota_enforced
- mongodb_storage_quota_maxfiles
- mongodb_storage_smallfiles
- mongodb_systemlog_logappend
- mongodb_systemlog_logrotate
- mongodb_systemlog_path
- mongodb_user
- mongodb_user_admin_password
- mongodb_user_admin_username
- mongodb_user_update_password
- mongodb_volumes
- mongodb_wirdtiger_config_string
- mongodb_wiredtiger_cache_size
- mongodb_wiredtiger_config_string
- mongodb_wiredtiger_directory_for_indexes
- Discovered Tags
- Dependencies
- License
- Author
Requirements
- Minimum Ansible version:
2.10
Default Variables
mongodb_admin_update_password
Define when root admin password should be changed
Default value
mongodb_admin_update_password: always
mongodb_backup_addition_script
Additional commands at the end of the script
Default value
mongodb_backup_addition_script:
mongodb_backup_cron
A simple cron timing definition like hourly, daily or weekly
Default value
mongodb_backup_cron: daily
mongodb_backup_enabled
Enable or disable the backup script
Default value
mongodb_backup_enabled: false
mongodb_backup_formatting
Date format for the backup folder name
Default value
mongodb_backup_formatting: '%F'
mongodb_backup_ignore
Ignoring this filter via grep on database selection
Default value
mongodb_backup_ignore: (admin|local)
mongodb_backup_path
Path to store the backups
Default value
mongodb_backup_path: '{{ mongodb_storage_path }}/_backup'
mongodb_backup_retention
Retention period to keep backups
Default value
mongodb_backup_retention: 7
mongodb_cloud_monitoring_free_state
Define parameters for mongod config
Default value
mongodb_cloud_monitoring_free_state: off
mongodb_exporter_args
List of arguments joined for the executable
Default value
mongodb_exporter_args: []
mongodb_exporter_collect_collection
Enable collector for collections
Default value
mongodb_exporter_collect_collection: false
mongodb_exporter_collect_database
Enable collector for databases
Default value
mongodb_exporter_collect_database: true
mongodb_exporter_collect_indexusage
Enable collector for index usage
Default value
mongodb_exporter_collect_indexusage: false
mongodb_exporter_collect_replicaset
Default value
mongodb_exporter_collect_replicaset: true
mongodb_exporter_collect_topmetrics
Enable collector for top metrics
Default value
mongodb_exporter_collect_topmetrics: true
mongodb_exporter_connection
Connection URI to access the MongoDB
Default value
mongodb_exporter_connection: mongodb://{% if mongodb_security_authorization == 'enabled'
%}{{ mongodb_metrics_username }}:{{ mongodb_metrics_password }}@{% endif %}localhost:27017
Example usage
mongodb_exporter_connection: mongodb://localhost:27017
mongodb_exporter_download
URL to the archive of the release to install
Default value
mongodb_exporter_download: https://github.com/percona/mongodb_exporter/releases/download/v{{
mongodb_exporter_version }}/mongodb_exporter-{{ mongodb_exporter_version }}.linux-amd64.tar.gz
mongodb_exporter_enabled
Enable the mongodb exporter
Default value
mongodb_exporter_enabled: true
mongodb_exporter_password
Default value
mongodb_exporter_password:
mongodb_exporter_username
Password to secure the metrics endpoint
Default value
mongodb_exporter_username:
mongodb_exporter_version
Version of the release to install
Default value
mongodb_exporter_version: 0.40.0
mongodb_extra_users
List of extra users to create
Default value
mongodb_extra_users: []
Example usage
mongodb_extra_users:
- username: username1
password: p455w0rd
roles: userAdminAnyDatabase
- username: username2
password: p455w0rd
roles:
- db: cool-app
role: read
update_password: on_create
mongodb_general_users
List of general users to create
Default value
mongodb_general_users: []
Example usage
mongodb_general_users:
- username: username1
password: p455w0rd
roles: userAdminAnyDatabase
- username: username2
password: p455w0rd
roles:
- db: cool-app
role: read
update_password: on_create
mongodb_group
Name of the group owning MongoDB
Default value
mongodb_group: mongodb
mongodb_keyfile_content
Key for inter-process auth, generate it with "openssl rand -base64 741"
Default value
mongodb_keyfile_content: |
dtHmRo7L02cY5WnMl/mrn6mjLkXpepzV39VQzulNJyglcYu9XW+tph8uI/dku082
IPf0tGttUb9KiogspyOyzVk+T1r3apLIGktu6YycdyHMqAzVrsS08cb7VecbcUKW
aODcxfRUYUGWCYjjVl8jm2x25hR4otakdHhxYi/B3eFEu2zWxvX3zgq78U0djQbl
qp9I7uyCsireT5SNj/A0H5QoCN6zMb7stNveas8W0N6+HfFVBD5brvVXGf5Td9Bz
EZ6e/69c7OtaNvbxEZP2SpkyZb7m0Q5vWs+YZyFWw7u9SBGXkUwTPVmVl0JLgHxA
ADOS2lYUdQCWTS1WT3D4nqfFn6xGikC6HK9SYVp5RG0EkRGRDJ9YiFa7lYRQmzJC
D+y2QECYXGT3pjl0u8B4AW8YgBkzcPCdD86PaZFxbycg6bvgSiwTJ/VfROnQ8crA
tBuYdy0r5fqshT7VOPw7dezhYjFiUYv2IspVGTB87ZkQxJ4GhKQIZB/31Rz216X7
944M6o7priJwWy9rJGk9YwSA18RoTlYNTXCdXQiUNmQl6Qd/zIVNDJ+cu1c7CwgF
zv//L5yDdTeP5YYEPf0DHW7gX2OGfdLjgkvXibpPPll3D6p5kwvRIcyOvVaCapSH
XJwrLJOidIjGC3UDS3+e17lNHHrw+/0ppYqh/0kfAMyZ2Si77T4jL5U3vSl3xAou
FFCMWXCyNE5/sngFIn5PDWZssQbel7mI5x9i4EZxreaSry0BUJK2ZUbPLGdW6F+I
tZiel1zZrVHPce+BAJCsjOIxB8jlnEd3FTjhgm8fDIrWCuRCdQ6hBL7KluqZBU/g
6tp4/YjUC98GNQK4w52+8BzU07b/OM54JB6Q+fPhQc1VK9S4sUnG5YoB+NN426ji
Hj5YyWm1PLtbeXqSATUEuUR47KGnJxt5YZn0wnOPhEvTWZw+X0EfDahOj5HllSli
Y9dhyzeXLgAay/bKLUNaudEMNQYh
mongodb_keyfile_path
Path to store the keyfile content
Default value
mongodb_keyfile_path: /etc/mongod.key
mongodb_keyring
Path for the repository keyring
Default value
mongodb_keyring: /usr/share/keyrings/mongodb-{{ mongodb_server_version }}-archive-keyring.gpg
mongodb_limit_files
Limit for open files for the mongod service
Default value
mongodb_limit_files: 1048576
mongodb_limit_procs
Limit for processes for the mongod service
Default value
mongodb_limit_procs: 524288
mongodb_logrotate_retention
Retention for log rotation
Default value
mongodb_logrotate_retention: 14
mongodb_master_node
Define the inventory name of the master node, used for users and replset init
Default value
mongodb_master_node:
mongodb_metrics_password
Password used for metrics exports
Default value
mongodb_metrics_password: p455w0rd
mongodb_metrics_update_password
Define when metrics user password should be changed
Default value
mongodb_metrics_update_password: always
mongodb_metrics_username
Username used for metrics exports
Default value
mongodb_metrics_username: metrics
mongodb_net_bindip
Default value
mongodb_net_bindip: 127.0.0.1
mongodb_net_http_enabled
Enable HTTP interface
Default value
mongodb_net_http_enabled: false
mongodb_net_ipv6
Enable IPv6 support
Default value
mongodb_net_ipv6: false
mongodb_net_maxconns
Max number of simultaneous connections
Default value
mongodb_net_maxconns: 51200
mongodb_net_port
Default value
mongodb_net_port: 27017
mongodb_operation_profiling_mode
Mode for operation profiling
Default value
mongodb_operation_profiling_mode: off
mongodb_operation_profiling_slow_op_threshold_ms
Profiling slow operations threshold in ms
Default value
mongodb_operation_profiling_slow_op_threshold_ms: 100
mongodb_oplog_users
List of oplog users to create
Default value
mongodb_oplog_users: []
Example usage
mongodb_oplog_users:
- username: oplog1
password: p455w0rd
- username: oplog2
password: p455w0rd
update_password: on_create
mongodb_pidfile_path
Path to the pid file
Default value
mongodb_pidfile_path: /run/mongodb/mongod.pid
mongodb_pymongo_version
Default value
mongodb_pymongo_version: 3.12.3
mongodb_recursive_enforce_owner
Enforce recursively data ownership
Default value
mongodb_recursive_enforce_owner: false
mongodb_replication_enable_majority_read_concern
Enable or disable majority read concern, should be false for PSA
Default value
mongodb_replication_enable_majority_read_concern: true
mongodb_replication_oplogsize
Specifies a maximum size in megabytes for the replication operation log
Default value
mongodb_replication_oplogsize: 1024
mongodb_replication_params
Replication host configuration or parameters
Default value
mongodb_replication_params:
Example usage
mongodb_replication_params:
- host_name: mongo-01,
host_port: "{{ mongodb_net_port }}"
host_type: replica
- host_name: mongo-02
host_port: "{{ mongodb_net_port }}"
host_type: replica
- host_name: mongo-03
host_port: "{{ mongodb_net_port }}"
host_type: replica
mongodb_replication_replindexprefetch
Specify index prefetching behavior if secondary like none, _id_only, all
Default value
mongodb_replication_replindexprefetch: all
mongodb_replication_replset
Enable replication in the form of
Default value
mongodb_replication_replset:
mongodb_root_admin_password
Default value
mongodb_root_admin_password: p455w0rd
mongodb_root_admin_username
Default value
mongodb_root_admin_username: root
mongodb_root_update_password
Define when root admin password should be changed
Default value
mongodb_root_update_password: always
mongodb_security_authorization
Disable or enable security
Default value
mongodb_security_authorization: disabled
mongodb_security_javascript_enabled
Enable javascript integration
Default value
mongodb_security_javascript_enabled: false
mongodb_server_version
Specify the port number to listen to
Default value
mongodb_server_version: '4.0'
mongodb_set_parameters
Default value
mongodb_set_parameters: {}
Example usage
mongodb_set_parameters:
enableLocalhostAuthBypass: "true"
authenticationMechanisms: SCRAM-SHA-1,MONGODB-CR
mongodb_storage_dirperdb
Use one directory per database
Default value
mongodb_storage_dirperdb: false
mongodb_storage_engine
Default value
mongodb_storage_engine: wiredTiger
mongodb_storage_journal_enabled
Enable journaling
Default value
mongodb_storage_journal_enabled: true
mongodb_storage_path
Default value
mongodb_storage_path: /var/lib/mongodb
mongodb_storage_quota_enforced
Limit each database to a certain number of files
Default value
mongodb_storage_quota_enforced: false
mongodb_storage_quota_maxfiles
Number of quota files per database
Default value
mongodb_storage_quota_maxfiles: 8
mongodb_storage_smallfiles
Very useful for non-data nodes
Default value
mongodb_storage_smallfiles: false
mongodb_systemlog_logappend
Append to the logging file
Default value
mongodb_systemlog_logappend: true
mongodb_systemlog_logrotate
Define the used storage engine
Default value
mongodb_systemlog_logrotate: reopen
mongodb_systemlog_path
Path to the logging file
Default value
mongodb_systemlog_path: /var/log/mongodb/mongod.log
mongodb_user
Name of the user owning MongoDB
Default value
mongodb_user: mongodb
mongodb_user_admin_password
Default value
mongodb_user_admin_password: p455w0rd
mongodb_user_admin_username
Default value
mongodb_user_admin_username: siteUserAdmin
mongodb_user_update_password
Define when user admin password should be changed
Default value
mongodb_user_update_password: on_create
mongodb_volumes
List of volumes/disks used to store the data tweaked by blockdev
Default value
mongodb_volumes: []
mongodb_wirdtiger_config_string
Config String for the wiredtiger engine
mongodb_wiredtiger_cache_size
Cache size for wiredtiger cache size
Default value
mongodb_wiredtiger_cache_size:
mongodb_wiredtiger_config_string
Default value
mongodb_wiredtiger_config_string:
mongodb_wiredtiger_directory_for_indexes
Directory per index for wiredtiger engine
Default value
mongodb_wiredtiger_directory_for_indexes: true
Discovered Tags
mongodb
mongodb-exporter
Dependencies
License
Apache-2.0
Author
Ansible role to install and configure a MongoDB object/document-oriented database
ansible-galaxy install rolehippie.mongodb