Hi@Shashi,
I think for MongoDB you need to add an extra repo in your system. It will not come with your CentOS DVD. So first create one repo file and copy the lines in a file as shown below.
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
After you saved this file in your Ansible node. Now you are ready to setup MongoDB. Create one playbook and write down the below code on that playbook.
- hosts: "Replace IP"
tasks:
- name: Copy file with owner and permissions
copy:
src: /mongo.repo(repo file name that you have to create as shown above)
dest: /etc/yum.repos.d/
- name: Install mongodb-org package
yum:
name: mongodb-org
state: present
- name: Start the service
service:
name: mongod
state: started
Now run the playbook with the help of the below command.
$ ansible-playbook demo.yml
Hope this helps!!
To know more about Mongodb, it's recommended to join Mongodb course online today.
Thanks!