This Ansible playbook automates the setup of a MongoDB cluster on both Debian and Redhat family distributions. It provides flexibility in configuring the storage path and allows modifications to the MongoDB configuration based on specific requirements.
mongodb-ansible
├── files
│ └── mongodb-enterprise-4.2.repo
├── handlers
│ └── main.yml
├── tasks
│ ├── centOS.yaml
│ ├── debian.yml
│ └── main.yml
├── templates
│ ├── mongodc.j2 --------->For CentOS/Redhat
│ └── mongodd.j2 --------> For Ubuntu/Debian
└── vars
└── main.yml
To run the playbook, follow these steps:
-
Modify Hosts File: Update the
hosts
file with the appropriate host information. -
Run the Command:
ansible-playbook -i ./hosts --private-key ~/.ssh/id_rsa -b mongo-db-main.yaml
Note: Replace
mongo-db-main.yaml
with the name of your playbook file.
-
Default Paths:
- For Debian family:
/opt/mongodb/data/
- For Redhat family:
/var/lib/mongo/
Modify the default paths in the variable file located in the
vars
directory if necessary. - For Debian family:
-
Customization:
- Adjust the configuration file (in the
templates
directory) to meet specific requirements.
- Adjust the configuration file (in the
Ensure the private key (id_rsa
) is available for authentication.
This playbook simplifies the deployment of MongoDB clusters, providing a standardized and efficient solution for managing MongoDB installations across different Linux distributions. Contributions and feedback are welcome for further enhancements and optimizations.