Configure-MongoDB-ReplicaSets-using-Ansible

Configure MongoDB replica sets using Ansible

Stars
0
Committers
1

Configure MongoDB replica sets

This guide provides steps to configure MongoDB replica sets using Ansible for automated deployment. Replica sets ensure high availability and data redundancy by replicating data across multiple MongoDB instances.

Architecture

Requiments

  • Ansible installed on the control node.
  • A set of MongoDB instances configured on saparate hosts.
  • SSH access to MongoDB servers.
  • MongoDB installed on all instances.

Steps

  1. Clone the repo
git clone https://github.com/th1enlm02/Configure-MongoDB-ReplicaSets-using-Ansible.git
cd Configure-MongoDB-ReplicaSets-using-Ansible
  1. Update inventory file and variables in .roles/mongodb_repl_set/vars/main.yml

  2. Run the playbook

ansible-playbook -i ./inventory site.yml
  1. Verify the Replica Set

After the playbook runs, log in to any of the MongoDB instances and check the status of the replica set:

mongosh --eval "rs.status()"