How to install mongodb on centos 7 using ansible

0 votes
Sep 16, 2020 in Ansible by Shashi
• 370 points
3,902 views

1 answer to this question.

0 votes

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!

answered Sep 16, 2020 by MD
• 95,460 points

Related Questions In Ansible

0 votes
1 answer

Unable to install Ansible on centOS

Seems like you're stuck at creating ansible ...READ MORE

answered Dec 20, 2018 in Ansible by Alan
705 views
0 votes
1 answer

How to move/rename a file using an Ansible task on a remote system?

Hi@akhtar, You can use the command module to ...READ MORE

answered Sep 17, 2020 in Ansible by MD
• 95,460 points
20,596 views
0 votes
1 answer

How to write ansible playbook to setup ubuntu workstation and install any updates on it

Hi@Shashi, Ansible has one module named ec2. This is ...READ MORE

answered Nov 19, 2020 in Ansible by MD
• 95,460 points
1,309 views
0 votes
1 answer

How to install python package using Ansible playbook?

Hi@akhtar, Ansible has a pip module to install ...READ MORE

answered Dec 2, 2020 in Ansible by MD
• 95,460 points
4,383 views
0 votes
1 answer

How to create a simple S3 bucket on Ceph Rados Gateway using Ansible Playbook?

Hi@MD, Ansible has one module that can create ...READ MORE

answered Dec 4, 2020 in Ansible by akhtar
• 38,260 points
1,330 views
0 votes
1 answer

How to create ECS service on VPC network using Ansible Playbook?

Hi@akhtar, An Amazon ECS service enables you to run and ...READ MORE

answered Dec 4, 2020 in Ansible by MD
• 95,460 points
1,016 views
0 votes
1 answer

How to install httpd web server in remote node using Ansible?

Hi@akhtar, You need to use the package module in Ansible. ...READ MORE

answered Jul 30, 2020 in Ansible by MD
• 95,460 points
2,614 views
0 votes
1 answer

How to create a key pair on AWS using Ansible-Playbook?

Hi@akhtar, You can find the ec2_key module in ...READ MORE

answered Aug 12, 2020 in Ansible by MD
• 95,460 points
1,478 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP