iquzart.mongodb
Ansible MongoDB
This is an Ansible role for setting up MongoDB with support for Replicasets.
Features
- Works with CentOS and Ubuntu
- Can set up Standalone or Replicaset configurations
- Sets up SELinux on CentOS
- Configures Firewalld
- Allows changing the MongoDB config file location
- Custom database and log directory options
- Can enable or disable authentication (enabled by default and recommended)
- Creates user accounts: Root, DBAdmin, Backup Admin
- Allows configuration of replica priority
- Supports SCARM Authentication
Support Matrix
OS | MongoDB 4.4 | MongoDB 4.3 |
---|---|---|
CentOS 8 | Supported (Tested) | Supported (Not Tested) |
CentOS 7 | Supported (Tested) | Supported (Not Tested) |
Ubuntu 20.04 LTS | Supported (Tested) | Supported (Not Tested) |
Ubuntu 19.04 LTS | Supported (Tested) | Supported (Not Tested) |
Role Variables
# MongoDB Version
mongodb_install_version_major: 4
mongodb_install_version_minor: 4
mongodb_install_version_patch: "*"
# CentOS Settings
mongodb_enable_yum_repository: true
mongodb_install_package_lock: true
# Ubuntu Settings
mongodb_enable_apt_repository: true
# SELinux Configuration (only for CentOS)
configure_selinux: True
# MongoDB Configuration
mongodb_conf_file: /etc/mongodb/mongod.conf
mongodb_conf_db_dir: /data/mongo-data
mongodb_conf_log_dir: /var/log/mongodb
mongodb_conf_dbEngine: wiredTiger
mongodb_conf_auth: true
mongodb_conf_bindIp: "0.0.0.0"
mongodb_conf_journal: true
mongodb_conf_maxConns: 64000
mongodb_conf_port: 27017
mongodb_conf_oplogSize: 1024
mongodb_conf_cloudmonitoring: "off"
# Systemd Units
mongodb_daemon_unitfile: /etc/systemd/system/mongod.service
# Replicaset Configuration
mongodb_replication_enabled: true # false creates a standalone MongoDB instance
mongodb_replication_key_file: /etc/mongodb/repl.key
mongodb_replication_set_name: rs01
# PyMongo Configuration
mongodb_pymongo_pip_version: 3.7.1
# Account Configuration
mongodb_root_account: root
mongodb_root_password: "p@ssw0rd"
mongodb_admin_account: dbadmin
mongodb_admin_password: "p@ssw0rd"
mongodb_backup_account: backupadmin
mongodb_backup_password: "p@ssw0rd"
Example Playbook
- name: MongoDB Setup
hosts: mongo
remote_user: root
become: yes
roles:
- mongodb-replicaset
Host Inventory
all:
hosts:
children:
mongo:
hosts:
mongo-01.example.com:
host_name: mongodb-01
host_ip: "192.168.122.201"
mongo-02.example.com:
host_name: mongodb-02
host_ip: "192.168.122.202"
mongo-03.example.com:
host_name: mongodb-03
host_ip: "192.168.122.203"
master:
hosts:
mongo-01.example.com:
replicas:
hosts:
mongo-02.example.com:
priority: 1
mongo-03.example.com:
priority: 1
arbiter:
hosts:
# mongo-03.example.com:
# priority: 0
Optional Requirement
- CentOS Baseline - Ansible Role
License
MIT
To-Do
- Add TLS support
- Add x509 Authentication Support
Author Information
Muhammed Iqbal iquzart@hotmail.com
Informazioni sul progetto
Install MongoDB standalone or Replicaset
Installa
ansible-galaxy install iquzart.mongodb
Licenza
Unknown
Download
69
Proprietario
Open Source Enthusiast