Stouts.mongodb
Stouts.mongo
This is an Ansible role used to manage MongoDB.
- Installs and configures MongoDB.
- Provides handlers to restart and reload MongoDB.
- Sets up the MMS automation agent.
Variables
Here are some configuration options you can set in your YAML file:
mongodb_enabled: yes
mongodb_install: yes
mongodb_additional_packages:
- python-selinux
- python-pymongo
mongodb_user: mongodb
mongodb_version: "3.2.4" # Specify the version of MongoDB to install
# Service setup options
mongodb_version_config: # Configuration for different MongoDB versions
v2.4:
daemon: mongodb
config_file: mongodb.conf
v2.6:
daemon: mongod
config_file: mongod.conf
v3.0:
daemon: mongod
config_file: mongod.conf
v3.2:
daemon: mongod
config_file: mongod.conf
# Configuration options
mongodb_conf_auth: no # Enable security
mongodb_conf_bind_ip: 127.0.0.1 # IP addresses to listen on, separated by commas
mongodb_conf_cpu: yes # Show CPU and I/O wait usage
mongodb_conf_dbpath: /data/db # Directory for data files
mongodb_conf_fork: no # Run server as a background process
mongodb_conf_httpinterface: no # Disable HTTP interface
mongodb_conf_ipv6: no # Disable IPv6 support
mongodb_conf_journal: no # Disable journaling
mongodb_conf_logappend: yes # Append to log instead of overwriting
mongodb_conf_logpath: /var/log/mongodb/{{ mongodb_daemon_name }}.log # Log file path
mongodb_conf_maxConns: 20000 # Maximum simultaneous connections
mongodb_conf_noprealloc: no # Disable data file preallocation
mongodb_conf_noscripting: no # Disable the scripting engine
mongodb_conf_notablescan: no # Disable table scans
mongodb_conf_port: 27017 # Port number to use
mongodb_conf_quota: no # Disable file limits per database
mongodb_conf_quotaFiles: 8 # Maximum number of quota files
mongodb_conf_syslog: no # Disable logging to the system log
mongodb_conf_smallfiles: no # Use smaller default file sizes
# Replica set options:
mongodb_conf_replSet: # Enable replication
mongodb_conf_replIndexPrefetch: all # Specify index prefetching behavior
mongodb_shell: {} # Mongo shell commands to run
# Syntax: mongodb_shell:
# dbname:
# - db.setProfilingLevel(1, 50)
# MMS Agent
mongodb_mms_agent_pkg: https://mms.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.deb
mongodb_mms_group_id: ""
mongodb_mms_api_key: ""
mongodb_mms_base_url: https://mms.mongodb.com
# Log rotation
mongodb_logrotate: yes # Enable log rotation for MongoDB.
mongodb_logrotate_options:
- compress
- copytruncate
- daily
- dateext
- rotate 7
- size 10M
Usage
To use this role, add Stouts.mongodb
to your roles and set the variables in your playbook file.
Example:
- hosts: all
roles:
- Stouts.mongodb
vars:
mongodb_conf_port: 27400
License
This project is licensed under the MIT License. Check the LICENSE file for details.
Feedback, Bug Reports, Requests...
Your feedback is welcome!