Write an ansible playbook to configure 3 VMs in Amazon AWS as a Mongo DB cluster.
- Create and download key pair from: AWS EC2 Keypair Link
- SSH setup:
- ssh-agent bash
- ssh-add {LocationToPemFile}
- Generate three Elastic IPs from: AWS Elastic IPs Link
- Create or modify a security group to allow all traffic(inbound and outbound) at: AWS Security Group Link
NOTE: write down the security group name - Launch three EC2 ubuntu instances from: AWS EC2 Instance Link
NOTE: Use the same security group you previously modified. After launching one instance, can use 'launch more like this' to simplify - Attach the previously created Elastic IPs to the EC2 instances
- Make the elastic IP entries in the 'hosts' file under groups
- [mongod_primary]: One Instance IP
- [mongod_secondary]: Two Instance IPs
- ssh-keygen -f "/home/{yourusername}/.ssh/known_hosts" -R {IP}
NOTE: Only if required, i.e., Key signature changes on every time an instance is destroyed and created. - ssh-keyscan {IP} >> ~/.ssh/known_hosts
NOTE: Add instance signatures to known hosts - use the script.sh to run the playbook
- Nasrulla Khan Haris
- Prashant Narayan Kulkarni
- Ujwal Komarla